ECHO-MAIL is a mass mailing solution that leverages AWS services to efficiently send emails at scale.
ECHO-MAIL is designed for sending bulk emails efficiently using AWS resources (Lambda
, S3
, EC2
). The project is built to scale, ensuring that emails are delivered reliably.
- AWS Lambda: Handles the business logic for sending emails. A request layer is included in the Lambda function to process API requests.
- AWS S3: Stores email templates, configurations, or any other relevant assets.
- AWS EC2: Runs the SMTP server, handling email transmission.
- SMTP Protocol: Used for sending emails from the EC2 instance.
- API Gateway: Provides a RESTful API interface for interacting with the Lambda function.
- AWS Account
- AWS CLI installed and configured
- Basic knowledge of AWS services (Lambda, S3, EC2, API Gateway)
- Docker (optional, if using Docker for local testing)
- Clone the Repository
git clone https://github.com/Atul-Kumar-Rana/Echo-Mail.git
cd Echo-Mail
-
Launch an EC2 Instance: Choose an appropriate instance type and configure security groups to allow
SMTP
(port 25),HTTP
(port 80), and traffic on port 5000. -
Change Inbound Rules:
-
Install Packages:
sudo apt-get update && upgrade sudo apt-get install python3.10-venv
-
Setup Python venv and Script
python3 -m venv venv source venv/bin/activate pip install boto3 flask touch EC2_code.py
Copy the contents of
EC2_code.py
from the repository with any code editor (vim, nano etc.).python3 EC2_code.py
Run the
EC2_code.py
to start the SMTP server and the associated Flask API to listen for incoming requests.
-
Configure IAM Roles:
- Create an IAM role for Lambda with the following permissions:
- Access to S3 for retrieving email templates.
- Permissions to send logs to CloudWatch.
- Any other permissions required by your Lambda function.
- Create an IAM role for Lambda with the following permissions:
-
Attach IAM Role to Lambda:
- Attach the IAM role to your Lambda function to grant it the necessary permissions.
-
Attach Request Layer:
- Upload
requests_layer.zip
:- Go to the AWS Lambda console.
- Select your Lambda function.
- Navigate to the "Layers" section and click "Add a layer."
- Choose "Upload a .zip file" and upload the
requests_layer.zip
file from your repository. - Configure the layer and add it to your Lambda function.
- Upload
-
Set Up API Gateway:
- Create a new API in API Gateway.
- Set up a resource and method (e.g., POST) to trigger the Lambda function.
- Deploy the API and note the endpoint URL for testing.
-
Configure Lambda Environment Variables:
- The necessary environment variables are already defined within the Lambda function code. These variables should be configured in the Lambda environment settings:
SMTP_HOST
SMTP_USER
SMTP_PASS
Subject
body
To set these environment variables in AWS Lambda:
- Go to the AWS Lambda console.
- Select your Lambda function.
- Navigate to the "Configuration" tab and select "Environment variables."
- Add the key-value pairs for
SMTP_HOST
,SMTP_USER
,SMTP_PASS
,Subject
, andbody
.
- The necessary environment variables are already defined within the Lambda function code. These variables should be configured in the Lambda environment settings:
- Upload Email Templates: Place your email templates in the S3 bucket.
- Trigger Lambda Function:
- Use API Gateway to call the Lambda function with the appropriate HTTP request.
- Alternatively, trigger Lambda via other events (e.g., scheduled CloudWatch event).
- Monitor Email Sending: Logs and metrics can be monitored in CloudWatch to ensure successful email delivery.
To test the Lambda function, you can use the test event JSON file provided in the repository. Follow these steps:
-
Attach the Test Event:
- Go to your Lambda function in the AWS Management Console.
- Click on "Test" and then "Configure test event."
- Upload the test event JSON file (
TestEvent.json
) from the repository.
-
Run the Test:
- Click on the "Test" button to trigger the Lambda function with the provided test event.
- Check the output and CloudWatch logs to ensure everything is working correctly.
As we send a PUT request through the API gateway, it will upload the file to S3 and trigger the Lambda function.
CSV file Format
- Core Functionality
- UI Design
- Application Dashboard
- Mailing Report Generation