Complete Guide: Sending Emails via AWS SES using SMTP

70 记录 , , , Leave a Comment

While I started to send email via AWS SES, it took me a long time to config it to make it working.

So I wrote it down once I success doing it.

Here are the important poinits:

  1. Verified identities
  2. Create SMTP credentials
  3. Send email with smtplib
  4. Raise ticket to AWS (default the SMTP is in sandbox, you can only send emails to the Verified identities)

Step 1: Verified identities

Let’s verifield 2 identities.

We will send a test email from the domain email to exact email later.

Step3: Create SMTP credentials

"User name" can be anyone, or keep it as default one.

Then Download .csv file of the credentials.

In the csv file, it give us SMTP user name and SMTP password. Actually, we can’t use it to send email with SMTP lib. It’s IAM key and secret.

Step3: Python code

import smtplib

# Please confirm the region should be exactly same as the one you create credentials
smtp_server = ''
smtp_port = 587

# AWS SES credentials (Replace with your own)
aws_access_key = '<SMTP user name from csv file>'
aws_secret_key = '<SMTP password from csv file>'

# Sender and recipient email addresses
sender_email = '[email protected]'
recipient_email = '[email protected]'

# Compose your email message
subject = 'A test email title'
body = 'Your email body.'
message = f'Subject: {subject}\n\n{body}'

with smtplib.SMTP(smtp_server, smtp_port) as smtp_client:
    smtp_client.login(aws_access_key, aws_secret_key)
    smtp_client.sendmail(sender_email, recipient_email, message)

Step 4: Raise ticket to AWS

Click here to raise the ticket

The "Use case description" should contain:

how often you send email, how you maintain your recipient lists, your website or app(please include any necessary links), and how you manage bounces, complaints, and unsubscribe requests. It is also helpful to provide examples of the email you plan to send so we can ensure that you are sending high-quality content.


Leave a Reply

Your email address will not be published. Required fields are marked *

Name *