Skip to content
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

Merged
merged 2 commits into from May 6, 2014
Merged

Add bcc to destinations #53

merged 2 commits into from May 6, 2014

Conversation

rdunlop
Copy link
Contributor

@rdunlop rdunlop commented May 6, 2014

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.

@drewblas
Copy link
Owner

drewblas commented May 6, 2014

Thanks. Is it your belief that this is the cause of #16 and this PR fixes it so BCC works?

@rdunlop
Copy link
Contributor Author

rdunlop commented May 6, 2014

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.

@drewblas
Copy link
Owner

drewblas commented May 6, 2014

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:

message = Mail.new({:from => 'jon@example.com', :bcc => "robin@example.com", :to => 'dave@example.com', :subject => 'Subject1', :body => "test body"})
package = @base.send("build_raw_email", message)
assert_equal 'dave@example.com',  package['Destinations.member.1']
assert_equal 'robin@example.com', package['Destinations.member.2']

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?

@rdunlop
Copy link
Contributor Author

rdunlop commented May 6, 2014

This is how I think it works:

  • When using sendRawEmail, it takes in a base64-encoded message, and sends that (RAW) across the wire to the destinations.
  • The "Destinations" are provided separately from the raw-message

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.

@drewblas
Copy link
Owner

drewblas commented May 6, 2014

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.

drewblas added a commit that referenced this pull request May 6, 2014
@drewblas drewblas merged commit 2b88ab0 into drewblas:master May 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants