This repository provides a Dockerized SMTP server setup using Postfix, configured to send emails via Gmail. This setup is ideal for local development environments where you need to test email functionality without relying on external SMTP servers.
- What is SMTP and SMTP Server?
- What is Postfix?
- What is a Gmail Application Password and How to Obtain It?
- Setup Instructions
- Usage
- Example
- Contributing
- License
SMTP (Simple Mail Transfer Protocol) is a communication protocol used for sending emails. An SMTP server is responsible for receiving and forwarding emails using this protocol.
Postfix is a popular open-source Mail Transfer Agent (MTA) used on Unix-based systems. It handles sending, receiving, and forwarding emails efficiently.
A Gmail Application Password is a secure way to access Gmail when using third-party applications or devices. It allows you to authenticate without using your regular Gmail password, ideal for SMTP configurations.
Before starting, ensure you have the following:
- Docker installed on your system.
-
Clone the Repository:
git clone https://github.com/your-username/smtp-server.git cd smtp-server
-
Create a
.env
File: Create a.env
file in the root directory with your Gmail credentials and SMTP settings:EMAIL=your-gmail-address EMAIL_PASSWORD=your-gmail-application-password PORT=25 MAIL_NAME=your-mailname SMTP_DOMAIN=smtp.gmail.com SMTP_PORT=587
-
Update
main.cf
: Modify themain.cf
file located in the root directory if necessary. This file contains Postfix configuration settings.
Build and run the Docker container using Docker Compose:
docker-compose up -d --build
Once the Docker container is running, you can send test emails from your local environment using the configured SMTP server.
Send a test email from the Docker container shell:
docker exec -it smtp-server sh
echo "This is a test email." | mail -s "Test Subject" [email protected]
Contributions are welcome! Please fork the repository and submit a pull request with your improvements.
This project is licensed under the MIT License - see the LICENSE file for details.