Files
web-drone/aws-ses-setup.md
2025-09-27 01:32:49 +01:00

4.5 KiB

AWS SES Setup Instructions

To enable email functionality for your PTSAerial contact forms using AWS SES, follow these steps:

1. AWS SES Setup

Verify Email Addresses

  1. Log into your AWS Console
  2. Go to Amazon SES service
  3. Navigate to "Verified identities"
  4. Add and verify these email addresses:
    • oli@ptslondon.co.uk (recipient)
    • noreply@ptslondon.co.uk (sender - must be from your domain)
  1. In SES, go to "Verified identities"
  2. Click "Create identity" > "Domain"
  3. Enter ptslondon.co.uk
  4. Follow DNS verification steps
  5. This allows sending from any address @ptslondon.co.uk

2. Create IAM User for Website

Create IAM Policy

  1. Go to IAM service in AWS Console
  2. Click "Policies" > "Create policy"
  3. Use JSON editor and paste:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ses:SendEmail",
                "ses:SendRawEmail"
            ],
            "Resource": "*"
        }
    ]
}
  1. Name it PTSAerial-SES-Send-Policy

Create IAM User

  1. Go to "Users" > "Create user"
  2. Username: ptsaerial-website
  3. Attach the policy you just created
  4. Create access keys for "Application running outside AWS"
  5. Save the Access Key ID and Secret Access Key securely

3. Update JavaScript Configuration

In your script.js file, update these values:

const awsConfig = {
    region: 'eu-west-1', // Your SES region (e.g., us-east-1, eu-west-1, us-west-2)
    accessKeyId: 'YOUR_ACCESS_KEY_ID', // From IAM user
    secretAccessKey: 'YOUR_SECRET_ACCESS_KEY', // From IAM user
};

And update the sender email:

Source: 'noreply@ptslondon.co.uk', // Must be verified in SES

4. SES Sandbox vs Production

If in Sandbox Mode (default):

  • Can only send to verified email addresses
  • Limited to 200 emails per day
  • Maximum 1 email per second

To Move to Production:

  1. In SES console, click "Request production access"
  2. Fill out the form explaining your use case
  3. AWS will review (usually approved within 24 hours)
  4. Production allows sending to any email address

5. Security Considerations

For Production Use (More Secure):

Instead of putting credentials in the frontend, consider:

  1. API Gateway + Lambda (Recommended):

    • Create a Lambda function to send emails
    • Use API Gateway to expose an endpoint
    • Call the API from your website
    • Credentials stay server-side
  2. Cognito Identity Pools:

    • Use temporary credentials
    • More secure than permanent access keys

Basic Frontend Implementation:

For testing/simple use, the current implementation works but:

  • Access keys are visible in the browser
  • Only use this for low-security scenarios
  • Consider IP restrictions in IAM policy

6. Test Configuration

  1. Update the configuration values in script.js
  2. Ensure SES is out of sandbox mode OR oli@ptslondon.co.uk is verified
  3. Test both contact forms
  4. Check oli@ptslondon.co.uk for emails
  5. Monitor AWS SES console for send statistics

7. Monitoring & Troubleshooting

SES Console Monitoring:

  • Check "Sending statistics" for delivery rates
  • Review "Suppression list" for bounced emails
  • Monitor "Reputation metrics"

Common Issues:

  • Invalid sender: Ensure sender email is verified
  • Access denied: Check IAM permissions
  • Sandbox restrictions: Verify recipient or request production access
  • Region mismatch: Ensure correct region in config

Browser Console Errors:

Check for:

  • AWS SDK loading errors
  • CORS issues (not applicable for SES)
  • Network connectivity
  • Invalid credentials

8. Email Content Details

Quote Request Emails Include:

  • Customer name, email, phone, company
  • Service type and location
  • Preferred date and budget range
  • Detailed project description
  • HTML formatted table for easy reading

Contact Form Emails Include:

  • Customer name, email, subject
  • Message content
  • Professional HTML formatting

9. Cost Information

AWS SES Pricing (as of 2025):

  • First 62,000 emails per month: $0.10 per 1,000 emails
  • Additional emails: $0.10 per 1,000 emails
  • No monthly fees
  • Very cost-effective for business use

10. Regional Recommendations

Choose your region based on:

  • eu-west-1 (Ireland): Good for UK business
  • us-east-1 (N. Virginia): Lowest cost, highest feature availability
  • eu-west-2 (London): UK data residency if required

Your current configuration uses eu-west-1 which is ideal for UK operations.