Demonstrates how to send email faster using AWS SES without a backend.
How it works
SES Mailer uses lambda to send mass email. It is invoked by S3 PUT event when a mailing list is dropped into the designated bucket. The function takes its message content from a HTML and plain text message file dropped in the same bucket. It sends multipart/alternative formatted emails.
ses_mailer.pyon AWS Lambda with a timeout setting of 5 minutes. Make sure the lambda Role has S3 read/write permissions to the bucket and
ses:SendRawEmailpermission. Configure Lambda environment variables e.g
Create a S3 bucket and set
putevent to trigger this lambda function.
In the S3 events configuration, set the event suffix to
Write your html formatted email in file html_message.html and upload to S3 bucket.
Write the plain text version of your email message in file text_message.txt and upload to S3 bucket.
Create a mailing list file i.e mailing_list_14032016.csv with contents in the below csv format. Don't include first row as header fields.
Sender Name <firstname.lastname@example.org>, Recipient Name <email@example.com>, subject
Compress the file using gzip. e.g
gzip -kf mailing_list_14032016.csvcreates
Upload the gzipped file mailing_list_14032016.csv.gz to the S3 bucket and it will trigger this lambda function.
This function will start sending email to all addresses in the csv file and log failures in
Tip: You can send even faster by splitting email list into multiple smaller csv files when the number of addresses exceed over a few 100,000s or increase
MAX_THREADS environment variable value to something higher depending on your SES TPS limit.