This Python program utilizes the Amazon Simple Email Service (SES) to send emails with attachments to a list of recipients in parallel. It is designed to handle a specified rate limit to comply with SES restrictions.
Before running the program, ensure that you have set the following environment variables:
AWS_ACCESS_KEY_ID
: Your AWS Access Key ID.AWS_SECRET_ACCESS_KEY
: Your AWS Secret Access Key.REGION_NAME
: The AWS region where SES is configured.
-
Clone the repository:
git clone [email protected]:oswaldom-code/ses-mail-async-py.git cd ses-mail-async-py
-
Install the required Python packages:
pip install boto3
-
Create a folder named
attachments
in the same directory as the script and place the files you want to attach inside it. -
Create a file named
email_list.txt
containing the list of recipient emails, with each email on a new line. -
Create an HTML file named
email_content.html
containing the email content in HTML format. -
Run the script:
python ses-mail-async.py
The program will send emails to the specified recipients with the provided HTML content and attached files.
The program respects the SES rate limit by sending emails at a specified rate (11 emails per second by default) using a ThreadPoolExecutor.
Failed emails (if any) will be logged in a file named failed_emails.txt
for further investigation.
Feel free to customize the program to meet your specific needs.