Originally I found this which only vaguely pointed me in the right direction, so I thought I'd create a gist of what ended up working for me.
To add a CC address, you have to two two things
- Add the address to your recipeints array, and set the
header_tovalue to an address in thetofield. So if you're sending the email toto_address@domain.comand CCing it tocc_address@domain.com, theheader_toforcc_address@domain.comwill need to be set toto_address@domain.com - Add the email to the
CCheadersoption incontentobject. If you have multiple emails, these should be comma separated.
BCC Seems to be simpler than CC since it's only one step, you just need to repeat step #1 from CC and you're good to go.
- Add the address to your recipeints array, and set the
header_tovalue to an address in thetofield. So if you're sending the email toto_address@domain.comand BCCing it tobcc_address@domain.com, theheader_toforbcc_address@domain.comwill need to be set toto_address@domain.com
Below is an example which worked for me:
{
"content": {
"subject": "Test Message",
"html": "This is a test message.",
"headers": {
"CC": "some_cc_address@domain.com,some_other_cc_address@domain.com" // add all CC addresses here, comma separated
},
"from": {
"email": "some_from@domain.com",
"name": "Test Sender"
}
},
"recipients": [{
"address": {
"email": "to_address@domain.com",
"header_to": "to_address@domain.com"
}
}, {
"address": {
"email": "some_cc_address@domain.com",
"header_to": "to_address@domain.com" // note this address is the same as an address in the "to" field
}
}, {
"address": {
"email": "some_other_cc_address@domain.com",
"header_to": "to_address@domain.com" // note this address is the same as an address in the "to" field
}
}, {
"address": {
"email": "bcc_address@domain.com",
"header_to": "to_address@domain.com" // note this address is the same as an address in the "to" field
}
}
],
}