Configuring AWS SES Email Sending in Statamic: A Complete Guide

David Childs October 28th, 2024 Categories: Statamic AWS SES

Learn how to set up and configure Amazon SES for email sending in Statamic, including obtaining SMTP credentials, troubleshooting common issues, and following best practices for production deployment.

Configuring AWS SES Email Sending in Statamic: A Complete Guide

Email functionality is crucial for any modern website, whether it's for sending password resets, notifications, or marketing communications. In this guide, we'll walk through setting up Amazon Simple Email Service (SES) with Statamic, including how to obtain the necessary credentials and troubleshoot common issues.

Why AWS SES?

Amazon SES offers several advantages:

  • Highly scalable email sending
  • Competitive pricing
  • Excellent deliverability rates
  • Detailed analytics and tracking
  • Integration with other AWS services

Prerequisites

Before we begin, ensure you have:

  • An AWS account
  • A Statamic website up and running
  • Basic familiarity with AWS Console
  • Access to modify your website's DNS records

Step 1: Setting Up AWS SES

Verify Your Domain

  1. Log into the AWS Management Console
  2. Navigate to Simple Email Service (SES)
  3. Select "Verified Identities" from the left sidebar
  4. Click "Create Identity"
  5. Choose "Domain" as the identity type
  6. Enter your domain name
  7. Follow the provided DNS verification instructions
  8. Wait for domain verification (can take up to 72 hours)

Get SMTP Credentials

  1. In the AWS Console, navigate to SES
  2. Click on "SMTP settings" in the left sidebar
  3. Click "Create SMTP credentials" button
  4. Take note of the SMTP endpoint for your region
  5. You'll be redirected to create an IAM user
  6. Download or securely copy the generated credentials:
    • SMTP Username
    • SMTP Password

Important: Save these credentials immediately - you won't be able to access the SMTP password again!

Step 2: Configuring Statamic

Update Environment Variables

Add the following to your .env file:

MAIL_MAILER=smtp
MAIL_HOST=email-smtp.[your-region].amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=[Your SMTP Username]
MAIL_PASSWORD=[Your SMTP Password]
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=[your-verified-email@domain.com]
MAIL_FROM_NAME="${APP_NAME}"

Common Regional SMTP Endpoints

  • US East (N. Virginia): email-smtp.us-east-1.amazonaws.com
  • US West (Oregon): email-smtp.us-west-2.amazonaws.com
  • EU (Ireland): email-smtp.eu-west-1.amazonaws.com
  • Asia Pacific (Sydney): email-smtp.ap-southeast-2.amazonaws.com

Step 3: Testing the Configuration

Using Statamic's Email Utility

  1. Log into your Statamic Control Panel
  2. Navigate to Tools → Email
  3. Enter a test email address
  4. Click "Send Test Email"

Common Issues and Solutions

Signature Mismatch Error

If you see: "Request signature we calculated does not match the signature you provided"

  • Double-check that you're using SMTP credentials, not API credentials
  • Verify the SMTP username and password are correctly copied
  • Ensure you're using the correct regional endpoint

Email Not Sending

  1. Check if your AWS account is still in sandbox mode
  2. Verify that both sender and recipient emails are verified (required in sandbox mode)
  3. Confirm your SMTP credentials are correct
  4. Verify the encryption settings (TLS on port 587)

Production Considerations

  1. Request production access if you need to send to non-verified recipients:

    • Navigate to SES → Sending Statistics
    • Click "Request Production Access"
    • Fill out the form with your use case
  2. Monitor your sending limits:

    • Start with low volumes
    • Gradually increase sending as needed
    • Watch your bounce and complaint rates

Best Practices

1. Security

  • Never commit SMTP credentials to version control
  • Use environment variables for sensitive information
  • Regularly rotate SMTP credentials

2. Monitoring

  • Set up bounce and complaint notifications
  • Monitor your sending quotas
  • Keep track of your reputation metrics

3. Testing

  • Always test email functionality after configuration changes
  • Use a test email address before sending to real users
  • Consider setting up a staging environment with separate credentials

Conclusion

AWS SES provides a robust and scalable email solution for your Statamic website. While the initial setup requires careful attention to detail, the result is a reliable email sending system that can grow with your needs.

Remember to:

  • Keep your credentials secure
  • Monitor your sending metrics
  • Stay within AWS's acceptable use policies
  • Test thoroughly before sending to production

Need help? Consult the AWS SES Documentation or the Statamic Discussions for additional guidance.