ashwanikumarjha
Thu Oct 05 2023
Unsubscribe Feature when Email Service Provider is AWS SES
AWS SES List Management
• AWS SES provides built-in feature for managing email subscribers and their subscription preferences. This includes creating contact lists and topics, and enabling unsubscribe functionality directly in our emails.
• We need to create separate topics for different types of emails: To handle different types of emails like verification links
, subscription updates
, marketing
etc. we can create separate topics for each type of email. This allows us to manage the subscription preferences for each type of email separately.
• We need to Include the {{amazonSESUnsubscribeUrl}}
placeholder in our emails: AWS SES will automatically replace the {{amazonSESUnsubscribeUrl}}
placeholder in the email with the actual unsubscribe URL.
• When a user clicks on this link, they will be taken to an unsubscribe landing page hosted by AWS, where they can choose to opt-out of receiving emails for a specific topic or all topics.
• AWS SES will handle the process of updating the user's subscription status when they opt-out of a topic. The next time when our system tries to send an email to that user for the opted-out topic, AWS SES will not allow the email to be sent.
• Ensure important emails are not affected: To ensure that users can still receive important emails like OTP verification
and password reset
emails, even after they opt-out of other emails, we can use separate contact lists and topics for these types of emails or we should not pass ListManagementOptions
in these emails.
{
"Destination": {
"ToAddresses": ["user@example.com"]
},
"Message": {
"Body": {
"Html": {
"Charset": "UTF-8",
"Data": "<body> // Email content... <p>If you no longer wish to receive our emails, please <a href=" {{amazonSESUnsubscribeUrl}}">unsubscribe</a></p></body>"
}
},
"Subject": {
"Charset": "UTF-8",
"Data": "Email subject"
}
},
"Source": "sender@example.com",
"ListManagementOptions": {
"ContactListName": "contact_list_name",
"TopicName": "Marketing"
}
}