Relayer SMTP is a simple email relay server built with Rust, Actix Web, and Tokio. It provides an HTTP API for sending emails through a configured SMTP server.
- HTTP API for sending emails
- Configurable SMTP and server settings via environment variables
- Asynchronous email sending using Tokio
- Simple health check endpoint
src/main.rs
: Entry point of the applicationsrc/config.rs
: Configuration structures and loadingsrc/server.rs
: HTTP server implementationsrc/smtp_client.rs
: SMTP client implementationsrc/lib.rs
: Library functions and module declarationssrc/strings.rs
: Constant strings used in the project
- Clone the repository
- Copy
.env.example
to.env
and fill in the required environment variables:
SMTP_DOMAIN_NAME=your_smtp_domain
SMTP_LOGIN_ID=your_smtp_login
SMTP_LOGIN_PASSWORD=your_smtp_password
MESSAGE_ID_DOMAIN=your_message_id_domain
SERVER_HOST=localhost
SERVER_PORT=8080
- Run
cargo build
to compile the project
- Start the server:
cargo run
- The server will start on the configured host and port (default:
localhost:8080
)
Health check endpoint.
Response:
Hello, world!
Send an email using the SMTP relay service.
Sample Body:
curl -X POST http://localhost:3000/api/sendEmail \
-H "Content-Type: application/json" \
-d '{
"to": "[email protected]",
"subject": "Test Email",
"body_plain": "This is a test email.",
"body_html": "<html><body><p>This is a test email.</p></body></html>",
"reference": null,
"reply_to": null,
"body_attachments": null
}'
Success Response:
{
"message_id": "<[email protected]>",
"status": "success"
}