4.4 KiB
AWS SES Troubleshooting Guide
Your website now has enhanced error handling and logging. Here's how to troubleshoot email sending issues:
1. Check Browser Console
Open your website and:
- Press F12 to open Developer Tools
- Go to the "Console" tab
- Submit a test form
- Look for error messages
Common Console Messages:
Success:
AWS SES configured successfully
Attempting to send email with subject: New Quote Request - PTSAerial - [service]
Email sent successfully: {MessageId: "..."}
Common Errors:
AWS SDK not loaded. Please check the script tag.
Error configuring AWS: [error details]
SES Error: MessageRejected
SES Error: AccessDenied
SES Error: InvalidParameterValue
2. Common Issues & Solutions
Issue: "MessageRejected" Error
Cause: Email addresses not verified in SES Solution:
- Go to AWS SES Console
- Navigate to "Verified identities"
- Verify both
oli@ptslondon.co.ukandnoreply@ptslondon.co.uk - Check your email for verification links
Issue: "AccessDenied" Error
Cause: IAM user lacks SES permissions Solution:
- Go to AWS IAM Console
- Check your user has the SES policy attached
- Ensure policy includes
ses:SendEmailandses:SendRawEmail
Issue: "Sandbox" Restrictions
Cause: SES is in sandbox mode Solution:
- In SES Console, request production access
- Or verify all recipient email addresses
- Sandbox only allows verified recipients
Issue: "Region" Mismatch
Cause: Wrong AWS region in config Solution:
- Check which region your SES is set up in
- Update
region: 'eu-west-1'in script.js to match
Issue: "CORS" Errors
Cause: Browser security restrictions Solution:
- This shouldn't occur with SES, but if it does, consider using a backend API instead
3. Verify SES Setup
Check in AWS Console:
-
SES Dashboard → "Sending statistics"
- Should show attempted sends
- Check for bounce/complaint rates
-
Verified identities
oli@ptslondon.co.ukshould show "Verified"noreply@ptslondon.co.ukshould show "Verified"
-
Configuration sets (optional)
- Can help with tracking delivery
4. Test with Minimal Example
Add this to your browser console to test SES directly:
// Test AWS SES configuration
AWS.config.update({
region: 'eu-west-1',
accessKeyId: 'AKIA3C5Y7TIMPQ7PHLEM',
secretAccessKey: 'BPCPlS2X77KwgvFweOO3IebeT9U5gBNnZ5/7ZRX2WEtO'
});
const ses = new AWS.SES();
const params = {
Destination: { ToAddresses: ['oli@ptslondon.co.uk'] },
Message: {
Body: { Text: { Data: 'Test email from website' } },
Subject: { Data: 'Test Email' }
},
Source: 'noreply@ptslondon.co.uk'
};
ses.sendEmail(params, function(err, data) {
if (err) console.error('Error:', err);
else console.log('Success:', data);
});
5. Security Note
⚠️ Important: Your AWS credentials are currently visible in the browser source code. This is acceptable for testing but consider these alternatives for production:
Option A: Backend API (Recommended)
Create a simple backend endpoint that handles email sending:
// Instead of direct SES, call your API
fetch('/api/send-email', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData)
});
Option B: Cognito Identity Pool
Use temporary credentials instead of permanent access keys.
6. Alternative: Quick Backend Solution
If SES continues to have issues, here's a simple Node.js backend you could deploy:
// server.js
const express = require('express');
const AWS = require('aws-sdk');
const app = express();
AWS.config.update({
region: 'eu-west-1',
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_KEY
});
app.post('/send-email', (req, res) => {
const ses = new AWS.SES();
// Email sending logic here
});
7. Monitoring
Check these regularly:
- AWS SES bounce rate (keep under 5%)
- AWS SES complaint rate (keep under 0.1%)
- Your website's email delivery success rate
Next Steps
- Check browser console for specific error messages
- Verify email addresses in AWS SES
- Ensure SES is out of sandbox mode or recipients are verified
- Test with the minimal example above
- Consider implementing a backend API for production use
Let me know what specific error messages you see in the console!