Configuring AWS SES Email Sending in Statamic: A Complete Guide
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
- Log into the AWS Management Console
- Navigate to Simple Email Service (SES)
- Select "Verified Identities" from the left sidebar
- Click "Create Identity"
- Choose "Domain" as the identity type
- Enter your domain name
- Follow the provided DNS verification instructions
- Wait for domain verification (can take up to 72 hours)
Get SMTP Credentials
- In the AWS Console, navigate to SES
- Click on "SMTP settings" in the left sidebar
- Click "Create SMTP credentials" button
- Take note of the SMTP endpoint for your region
- You'll be redirected to create an IAM user
- 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
- Log into your Statamic Control Panel
- Navigate to Tools → Email
- Enter a test email address
- 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
- Check if your AWS account is still in sandbox mode
- Verify that both sender and recipient emails are verified (required in sandbox mode)
- Confirm your SMTP credentials are correct
- Verify the encryption settings (TLS on port 587)
Production Considerations
-
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
-
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.