Repository navigation
Honour opt-outs during sends, one-click unsubscribe, escape merge tags - #17
Merged
Merged
Conversation
…merge tags
- The send worker checks each email again before sending it: if the
recipient unsubscribed, bounced or complained after the campaign was
queued, the email is marked 'skipped' (new status, V2 migration) and
counted in campaign_jobs.skipped_count instead of being sent.
- Campaign emails carry List-Unsubscribe and List-Unsubscribe-Post
(RFC 8058 one-click, required by Gmail and Yahoo for bulk senders).
EmailSender takes extra headers; SES moves to SendRawEmail for them.
- GET /track/unsubscribe/{token} now only shows a confirmation page, so
link scanners can't unsubscribe people; POST does the unsubscribe.
- New SuppressionService: every opt-out (link, API, bounce, complaint)
sets the recipient's status and adds the address to the suppression
list. Unsubscribing via the email link previously skipped the list.
RecipientService normalises addresses, so a mixed-case re-add can't
bypass an opt-out, and complained recipients can't be re-added.
- Merge-tag values are HTML-escaped so imported data can't inject
markup or links into emails.
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.
Fixes four send-compliance problems found in an audit.
Problems
List-UnsubscribeorList-Unsubscribe-Postheaders, which Gmail and Yahoo require from bulk senders. Also,GET /track/unsubscribe/{token}unsubscribed straight away, so link scanners (Outlook Safe Links, Mimecast) unsubscribed people without their knowledge.RecipientServicedidn't normalise addresses. Together, these let a mixed-case re-add mail someone who had opted out.Changes
skippedqueue status and counted incampaign_jobs.skipped_count. Both come from the new migrationV2__queue_skipped.sql.job-statusreports the skipped count, and progress includes skipped emails.EmailSendergains asend(..., headers)overload. Resend and SMTP set the headers directly. SES switches fromSendEmailtoSendRawEmail, which is the only way to set custom headers, and still returns the SES message id for webhook matching.GET /track/unsubscribe/{token}now shows a confirmation page and changes nothing.POSTto the same URL does the unsubscribe. It handles both the page's button and RFC 8058 one-click.SuppressionService: every opt-out goes through it (email link, API, permanent bounce, complaint). It sets the recipient's status only if they are active, and adds the address to the suppression list withINSERT … ON CONFLICT DO NOTHING.RecipientService: normalises addresses, and refuses to re-add recipients who complained.Deploy notes
V2__queue_skipped.sqlruns at startup. It replaces the status check onemail_queueand adds a column with a default.ses:SendRawEmail. Without it, SES sends fail and fall back to SMTP.Testing
./gradlew test,integrationTestandscaleTestall pass locally.SuppressionServicenormalises addresses and changes only active recipients;