Skip to content

Simple Email Service

  • Simple Email Service is a SMTP server

SMTP Credentials

  • Console -> Amazon SES -> SMTP Settings

  • The SMTP credentials are generated based on an IAM User. You need to create an iam user specifically for SES

# Create SES user
aws iam create-user --user-name ses-smtp-user

# Attach the necessary policies to the user
aws iam attach-user-policy \
    --user-name ses-smtp-user \
    --policy-arn arn:aws:iam::aws:policy/AmazonSESFullAccess

# Generate Access Key
aws iam create-access-key --user-name ses-smtp-user
{
  "AccessKey": {
    "UserName": "ses-smtp-user",
    "AccessKeyId": "AKIAEXAMPLE",
    "SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
    "Status": "Active",
    "CreateDate": "2024-12-05T12:00:00Z"
  }
}
  • The SMTP user is the AccessKeyId
  • The SMTP password is derived from the SecretAccessKey. You can convert it
SECRET_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
echo -ne "\x02$(echo -n 'SendRawEmail' | openssl dgst -sha256 -hmac $SECRET_KEY -binary)" | base64

Sending E-Mails

# email.txt
From: "Your Name" <[email protected]>
To: [email protected]
Subject: Test Email from SES
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

This is a test email sent via AWS SES SMTP using curl.
set smtp_endpoint "smtp://email-smtp.us-east-1.amazonaws.com:587"
curl --url "$smtp_endpoint" \
  --ssl \
  --mail-from "[email protected]" \
  --mail-rcpt "[email protected]" \
  --upload-file email.txt \
  --user "SMTP_USERNAME:SMTP_PASSWORD"
#!/bin/bash

SMTP_HOST="email-smtp.us-east-1.amazonaws.com"
SMTP_PORT="587"
SMTP_USER="YOUR_SMTP_USERNAME"
SMTP_PASS="YOUR_SMTP_PASSWORD"
FROM="[email protected]"
TO="[email protected]"
SUBJECT="Test Email from SES"
BODY="This is a test email sent via AWS SES."

echo -e "From: $FROM\nTo: $TO\nSubject: $SUBJECT\n\n$BODY" > email.txt

curl --url "smtp://$SMTP_HOST:$SMTP_PORT" \
  --ssl \
  --mail-from "$FROM" \
  --mail-rcpt "$TO" \
  --upload-file email.txt \
  --user "$SMTP_USER:$SMTP_PASS"