New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bcc to destinations #53
Conversation
Overwrite the mail addresses if passed any via the args
Thanks. Is it your belief that this is the cause of #16 and this PR fixes it so BCC works? |
In short, Yes. While working on the PR, it became obvious that the message.to/message.cc/message.bcc aren't being used to build the destinations, and thus I found that if I don't specify any Destinations, the contents of the base64 encoded message are used for addresses. Once I start using "Destinations", the addresses within the base64 message are no longer used, and everything starts to make more sense. I believe that this fixes BCC, and it did work for my various tests against my AWS account. The documentation of AWS SES for SendRawEmail is a little lacking. |
Awesome. So the only thing that is confusing here is that "Destinations" doesn't seem to distinguish between types of recipients. e.g. in your test:
They all just becomes "members". So AWS must be looking at both the "Destinations" as well as the base64 message headers to determine how to address it? Are you certain these aren't being converted from bcc recipients to regular recipients? |
This is how I think it works:
As far as AWS is concerned, it doesn't need to know about what 'type' each recipient was, it only needs to know who to deliver each message to. (and each delivery will contain the same 'raw' message). The addressing of the message has already been done in the raw base64-encoding. Now we're just talking about transportation of the contents. This theory becomes a little more likely when you start thinking about BCC, and how that must get handled by servers. |
Got it, that starts to make some sense: The message (including the headers) is the same for everyone and doesn't include BCC recipients. Hence why there were going missing. |
It appears that the send_raw_email function was taking advantage of an undocumented feature:
If there are no "Destinations" specified, the raw Email (in the base64 encoding) addresses would be used.
Since "bcc" addresses never appear in the base64 encoding, and only in the "Destinations" field, this commit Always specifies a Destinations block now.
If there are any to/cc/bcc options, they overwrite the passed 'mail message' options. If not, the 'mail message' to/cc/bcc are used for the destinations.