Python Sparkpost email header - CC and BCC issue

294 Views Asked by At

When I use the below code, the email sends to all recipients, however, the email headers aren't set correctly as the CC recipient isn't appearing in the email, all recipients only see the main recipient appearing in the email.

Does anyone know why the CC recipient wouldn't show? The BCC isn't showing as expected but I am unsure if this is because the headers are incorrect.

         from sparkpost import SparkPost
         from sparkpost.exceptions import SparkPostAPIException


         sparky = SparkPost()

         sparky.transmissions.send(
            from_email={
                'email': sender,
                'name': "SenderName"
            },
            recipients=['[email protected]'],
            cc=['[email protected]'],
            bcc=['[email protected]'],
            template=template_id,
            subject=subject_line,
            ip_pool='mailer',
            track_opens=True,
            track_clicks=True,
            use_draft_template=True,
            substitution_data={
                'SUBJECT': "test",
                'ADDRESSEE': "test addressee",
                'CONTENT_STRING':"content",
                'SENDER': "[email protected]",
                'REPLY_TO': "[email protected]",
                'FROM_NAME': "Sender"
            }
        )
1

There are 1 best solutions below

0
James On

Just ran into this myself. You have to include your cc email(s) in both recipients and cc.

In your example, your recipients/cc would be updated to:

recipients=['[email protected]','[email protected]'],
cc=['[email protected]'],

From their documentation: (https://www.sparkpost.com/docs/faq/cc-bcc-with-rest-api/)

"Each recipient you want to send your message to must have an entry in your recipient list at transmission time. Setting the CC and BCC header does not affect the recipients SparkPost will deliver to, just the way the message appears in each recipient’s email client."