A dynamic email receiving and processing system built with AWS SES, Lambda, and Next.js that allows you to programmatically manage email addresses and automatically process incoming emails.
Inbound.exon.dev enables you to:
- Dynamically manage email addresses through your API
- Automatically receive emails for managed domains using AWS SES
- Process emails via Lambda with spam/virus filtering
- Store emails in S3 temporarily (auto-deleted after 90 days)
- Send real-time webhooks to your API when emails arrive
- Retrieve full email content on-demand from S3
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Email Sender βββββΆβ AWS SES βββββΆβ S3 Bucket β
β β β (Spam/Virus β β (Email Storage) β
β test@exon.dev β β Filtering) β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Your API ββββββ Lambda ββββββ SES Trigger β
β (Webhook β β (Email β β β
β Endpoint) β β Processor) β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Next.js β β CloudWatch β
β (Dashboard) β β (Logs/Metrics) β
βββββββββββββββββββ βββββββββββββββββββ
inbound.exon.dev/
βββ π aws/ # AWS Infrastructure
β βββ π cdk/ # CDK Infrastructure as Code
β βββ π lib/inbound-email-stack.ts # Main CDK stack definition
β βββ π bin/inbound-email-cdk.ts # CDK app entry point
β βββ π package.json # CDK dependencies
β βββ π cdk.json # CDK configuration
β
βββ π lambda/ # Lambda Functions
β βββ π email-processor/ # Email processing Lambda
β βββ π index.ts # Lambda handler entry point
β βββ π package.json # Lambda dependencies
β βββ π tsconfig.json # TypeScript config
β βββ π dist/ # Compiled Lambda code
β
βββ π lib/ # Shared Libraries
β βββ π aws-ses.ts # Email processing library
β
βββ π scripts/ # Deployment Scripts
β βββ π deploy-email-system.ts # Full deployment script
β βββ π quick-deploy.ts # Quick deployment script
β βββ π test-deployment.ts # Deployment verification
β
βββ π docs/ # Documentation
β βββ π DEPLOYMENT_GUIDE.md # Complete deployment guide
β βββ π LAMBDA_DEPLOYMENT.md # Lambda-specific setup
β βββ π DYNAMIC_EMAIL_MANAGEMENT.md # API integration guide
β
βββ π app/ # Next.js Application
βββ π (main)/ # Main app routes
βββ π api/ # API endpoints
βββ π components/ # React components
package.json
- Main project dependencies and deployment scripts.env
- Environment variables (API keys, AWS config)aws/cdk/lib/inbound-email-stack.ts
- Infrastructure definitionlambda/email-processor/index.ts
- Email processing logic
# 1. Install dependencies
bun install
# 2. Configure AWS CLI
aws configure
# Enter: Access Key ID, Secret Access Key, Region (us-east-2)
# 3. Bootstrap CDK (first time only)
cd aws/cdk && bun run cdk bootstrap
# Create .env file with your configuration
export SERVICE_API_URL="https://inbound.exon.dev"
export SERVICE_API_KEY="your-secret-api-key"
export EMAIL_DOMAINS="exon.dev,yourdomain.com"
export AWS_REGION="us-east-2"
The CDK stack now automatically outputs all required environment variables:
cd aws/cdk
npm install
./deploy.sh # Full deployment with environment variable extraction
This will deploy the infrastructure and display:
π DEPLOYMENT COMPLETE!
π Add these environment variables to your .env file:
# AWS Configuration for Email Processing
S3_BUCKET_NAME=inbound-emails-123456789012-us-west-2
AWS_ACCOUNT_ID=123456789012
LAMBDA_FUNCTION_NAME=inbound-email-processor
AWS_REGION=us-west-2
# Make sure you also have these (from your AWS credentials):
# AWS_ACCESS_KEY_ID=your_access_key_here
# AWS_SECRET_ACCESS_KEY=your_secret_key_here
1. Lambda Build β 2. CDK Synthesis β 3. AWS Deployment β 4. Verification
ββ TypeScript ββ Infrastructure ββ CloudFormation ββ Stack Status
ββ Dependencies ββ Asset Bundling ββ S3 Bucket ββ Lambda Test
ββ Dist Output ββ Template Gen ββ Lambda Function ββ SES Rules
ββ SES Rules ββ Monitoring
ββ IAM Permissions
# Deploy everything with defaults
bun run deploy:quick
# Deploy with custom configuration
SERVICE_API_URL=https://your-domain.com \
EMAIL_DOMAINS=yourdomain.com \
bun run deploy:quick
# 1. Build Lambda function only
bun run deploy:lambda
# 2. Deploy CDK infrastructure only
SERVICE_API_URL=https://your-domain.com bun run deploy:cdk
# 3. Deploy with full configuration options
bun run deploy:email --service-api-url https://your-domain.com \
--email-domains exon.dev,example.com \
--aws-region us-east-2
# 1. Build Lambda function
cd lambda/email-processor
bun install
bun run build
# 2. Build and deploy CDK
cd ../../aws/cdk
bun install
bun run build
SERVICE_API_URL=https://your-domain.com bun run cdk deploy
# Test the deployment
bun run test:deployment
# Test with specific region
AWS_REGION=us-east-2 bun run test:deployment
Expected Output:
π§ͺ Testing Email System Deployment
1οΈβ£ Testing AWS credentials...
β
AWS Account: 375612485665
2οΈβ£ Checking CloudFormation stack...
β
Stack Status: CREATE_COMPLETE
3οΈβ£ Testing Lambda function...
β
Lambda State: Active
β
Lambda Runtime: nodejs18.x
β
Lambda Memory: 512MB
4οΈβ£ Testing S3 bucket...
β
Email bucket found: inbound-emails-375612485665-us-east-2
5οΈβ£ Testing SES receipt rules...
β
Receipt rule set found with 1 rules
β
Deployment test completed!
# Verify your domain
aws ses verify-domain-identity --domain exon.dev --region us-east-2
# Check verification status
aws ses get-identity-verification-attributes --identities exon.dev --region us-east-2
Add these DNS records to your domain:
MX Record:
Type: MX
Name: @
Value: 10 inbound-smtp.us-east-2.amazonaws.com
TTL: 300
TXT Record (for domain verification):
Type: TXT
Name: @
Value: [Value from AWS SES verification]
TTL: 300
# Send email to any address at your domain
echo "Test email body" | mail -s "Test Subject" test@yourdomain.com
# Watch Lambda logs in real-time
aws logs tail /aws/lambda/inbound-email-processor --follow --region us-east-2
# Check recent Lambda invocations
aws logs describe-log-streams --log-group-name /aws/lambda/inbound-email-processor --region us-east-2
# View S3 bucket contents
aws s3 ls s3://inbound-emails-375612485665-us-east-2/emails/ --recursive
# Start Next.js development server
bun run dev
# Run in development mode with turbopack
bun run dev --turbo
# 1. Edit lambda/email-processor/index.ts
# 2. Build and deploy
bun run deploy:lambda
# 1. Edit aws/cdk/lib/inbound-email-stack.ts
# 2. Deploy changes
bun run deploy:cdk
# 1. Edit lib/aws-ses.ts
# 2. Rebuild Lambda
cd lambda/email-processor && bun run build
# 3. Deploy
bun run deploy:lambda
# View Lambda logs
aws logs tail /aws/lambda/inbound-email-processor --follow --region us-east-2
# Search for errors
aws logs filter-log-events --log-group-name /aws/lambda/inbound-email-processor \
--filter-pattern "ERROR" --region us-east-2
# View specific time range
aws logs filter-log-events --log-group-name /aws/lambda/inbound-email-processor \
--start-time 1640995200000 --end-time 1641081600000 --region us-east-2
- Lambda: Monitor invocations, duration, errors
- S3: Check email storage and lifecycle
- SES: View receipt metrics and bounce rates
- CloudWatch: Set up alarms for errors and performance
# Check AWS configuration
aws sts get-caller-identity
# List CloudFormation stacks
aws cloudformation list-stacks --region us-east-2
# Check Lambda function details
aws lambda get-function --function-name inbound-email-processor --region us-east-2
# Test Lambda manually
aws lambda invoke --function-name inbound-email-processor \
--payload file://test-event.json response.json --region us-east-2
# Update main project
bun update
# Update Lambda dependencies
cd lambda/email-processor && bun update
# Update CDK dependencies
cd aws/cdk && bun update
# Destroy all AWS resources
cd aws/cdk && bun run cdk destroy
# Clean build artifacts
rm -rf lambda/email-processor/dist
rm -r
6D47
f aws/cdk/cdk.out
# Start Docker Desktop
open -a Docker
# Or use pre-built Lambda approach (already configured)
bun run deploy:quick
# Check Lambda TypeScript config
cd lambda/email-processor
bun run build
# Fix import paths if needed
# Verify AWS credentials
aws sts get-caller-identity
# Check IAM permissions for SES, S3, Lambda, CloudFormation
- Check MX records:
dig MX yourdomain.com
- Verify domain in SES console
- Check SES sandbox mode
- Monitor CloudWatch logs
- AWS CLI configured and working
- Domain verified in AWS SES
- MX records pointing to AWS SES
- Lambda function deployed and active
- S3 bucket created with proper permissions
- SES receipt rules configured
- CloudWatch logs showing activity
- Full Deployment Guide - Complete setup instructions
- Lambda Deployment - Lambda-specific configuration
- Dynamic Email Management - API integration
- AWS SES Documentation - Official AWS docs
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Ready to receive emails? Run bun run deploy:quick
and follow the setup steps! π