How sparkpost edits email "to" and "cc" header?

39 views Asked by At

In sparkpost, if I was to send emails to "[email protected]", "[email protected]" & "[email protected]" & along with that have cc'ed email "[email protected]".

{
  "recipients": [
    {
      "address": {
        "email": "[email protected]"
      }
    },
    {
      "address": {
        "email": "[email protected]"
      }
    },
    {
      "address": {
        "email": "[email protected]"
      }
    },
    {
      "address": {
        "email": "[email protected]",
        "header_to": "[email protected];[email protected];[email protected]"
      }
    }
  ],
  "content": {
    "from": "[email protected]",
    "headers": {
      "CC": "[email protected]"
    },
    "subject": "To and CC",
    "text": "This mail was sent to many while CCing [email protected]."
  }
}

Here cc would only get 1 email, with all "to" addresses in email's to header. All other "to" emails would also get 1 email, where each recepient is only able to see 2 emails : his own & the cc email. My question is how do they do this? I have to replicate this to Amazon Ses raw email. I tried sending emails indiviually, but cc is getting n + 1 emails as there are n "to" & 1 of his own.

I tried to send email individually in Amazon ses raw email but cc gets n + 1 emails as he has been cc'ed in those n "to" emails.

1

There are 1 answers

3
tripleee On BEST ANSWER

The headers only matter for display purposes; what is actually being sent is determined by the SMTP envelope. There is no way to have individualized headers in each message other than by sending individualized messages. Probably behind the scenes, they split up the message into multiples after generating the Cc: copy.

In some more detail,

  • Generate a message with all the To: recipients in the headers, but only send it to the Cc: recipient
  • Then, for each To: recipient, generate and send a new message only to them

There are many questions about the difference between headers and envelope information. In very brief, SMTP lets you specify the sender with MAIL FROM:<[email protected]> and each recipient with RCPT TO:<[email protected]>; and then, you supply the message in the DATA transaction, including all the headers. (The headers will be updated by reach handling MTA; on delivery, the final MTA will usually put the envelope sender in Return-Path:, and optionally the final local recipient in Delivered-To:.)