Send cc and bcc through the six providers that were dropping them - #62
Merged
eelcoj merged 1 commit intoSep 7, 2026
Merged
Conversation
Options accepts cc: and bcc: on every email, but Mailgun, Mailjet, MailPace, Postmark, SendGrid and SparkPost never read them, so the addresses were discarded without a warning (Rails-Designer#58). Each provider now maps them through address_list, in the shape its own API takes: a comma-separated line for Mailgun, MailPace and Postmark; an array of address objects for Mailjet and SendGrid. SparkPost has no cc/bcc field, so the copies join recipients and only the cc addresses are repeated in the CC header, with header_to holding the To line so a bcc stays hidden. Reading the recipient lists through the same helper also fixes Mailjet, SendGrid and SparkPost sending several to: addresses as one malformed address (Rails-Designer#59). Loops and Userlist are left alone: their APIs address a single contact and have nowhere to put a copy.
Collaborator
|
Thanks again for this @pcbeingused333! ❤️ Will push a new version shorttly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #58.
Optionsacceptscc:andbcc:on every email, but six providers never read them, so the addresses went out discarded with no warning. This adds them, in the shape each API takes, through theaddress_listhelper from #61:cc/bcc, comma-separated linecc/bcc, comma-separated lineCc/Bcc, comma-separated lineCc/Bcc, array of{"Email" => …}cc/bccinside the personalization, array of{"email" => …}Empty and whitespace-only values are dropped rather than sent, same as the providers that already used the helper.
SparkPost
SparkPost has no cc/bcc field. Every copy is an entry in
recipients, and a copy is only shown as one if its address is repeated in theCCheader — so the difference between a cc and a bcc is the header, not the recipient list.header_tocarries the To line for all of them, which is also what keeps a bcc hidden: without it SparkPost sets each recipient's visible To to their own address, so the bcc would see itself addressed directly.No cc means no
headerskey at all, so a send without copies keeps the body it had.A second bug this fixes
Reading the recipients through the same helper also fixes #59. That issue is closed, but it still reproduces on
mainat 4d25da7 — and not only in Mailjet: SendGrid and SparkPost put a multi-addresstointo a single address object too.Happy to pull that out into its own PR if you'd rather review it separately, but it is the same one-line change per provider as the cc/bcc work, so splitting it would leave
Tobroken next to a workingCc.Left alone
Loops and Userlist address a single contact through a template API and have nowhere to put a copy, so they still ignore
cc/bcc. Worth a note in the README, or a raise, but that is a decision rather than a fix — happy to follow whichever you prefer.Tests
Postmark, SendGrid, SparkPost and MailPace had no test files; they have one now, covering the body shape, the empty-value handling and the auth header. Mailgun's and Mailjet's were extended.
bundle exec rake teston Ruby 3.4: 159 runs, 302 assertions, 0 failures, 0 errors.standardrbclean. Withlib/reverted and the new tests kept, 8 of them fail — verified rather than assumed.