SMTP (Simple Mail Transfer Protocol) is a protocol used to send emails over the internet. In this project, the email will first be forwarded through a forwarder built using the Python programming language. Then, the email will be sent to an SMTP server implemented with the Rust programming language, in accordance with the standards outlined in RFC 5321. This project aims to fulfill the final semester assignment for the Computer Systems and Networks course.
This system consists of four main components:
- Email Forwarder (Python): A Python-based service that forwards email data received from clients to the SMTP server.
- SMTP Server (Rust): A server written in Rust that receives forwarded emails and sends them to the recipient.
- HTTP Server (Node.js): An optional HTTP server that can be used to send email data via HTTP requests.
- Email Client (Rust): A simple command-line client written in Rust that sends email data to the Python email forwarder.
- Python 3.x (for Email Forwarder)
- Rust (for SMTP Server and Email Client)
- Node.js (optional, for HTTP server)
- Libraries:
serde
andserde_json
for serializing email data in Rust.tokio
for asynchronous operations in Rust.
- Ports:
- SMTP server listens on port
2525
. - Email forwarder listens on port
1239
. - HTTP server (if used) listens on port
8080
.
- SMTP server listens on port
-
Clone the repository:
cd forwarder
-
Install the required Python dependencies:
Although
smtplib
,email
, andjson
are part of the Python standard library, you can create a virtual environment to keep your project isolated.python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install any additional dependencies if needed:
pip install -r requirements.txt
-
Ensure you have Rust installed. If not, follow the installation instructions here: Install Rust.
-
Clone the SMTP server repository and build the server using Cargo:
cd server cargo build --release
-
The server will listen on port
2525
by default. You can change this configuration in the Rust server code if needed.
-
Install Node.js. You can download it from nodejs.org.
-
Navigate to the directory where the HTTP server files are located and install the dependencies:
cd web npm install
-
The HTTP server will be used to send email requests via HTTP.
-
Create a new Rust project (if you haven't already):
cd socket cargo build --release
The client will prompt you to input the recipient, subject, and body of the email. Once the email data is entered, it will be serialized to JSON and sent to the Email Forwarder (Python-based service), which will forward the email to the Rust SMTP server.
cargo run --release
The smtp server will listen on port 2525
Run the Python-based email forwarder:
python3 forwarder.py
The forwarder will listen on port 1239
for incoming email data. It forwards the email data to the Rust-based SMTP server, which will process it.
cargo run --release
Enter the recipient, subject, and body of the email when prompted.
You can use a Node.js-based HTTP server to display or view emails that have already been received and stored.
Start the HTTP server:
npm start
You can configure the following:
- SMTP Server Configuration: Modify the Rust SMTP server to change the port or add other configuration options.
- Email Forwarder: Configure the Python script to change the SMTP server or its behavior.
- Client Configuration: You can modify the Rust client to include additional email fields or change the way emails are sent.
This project is licensed under the MIT License - see the LICENSE.md file for details.