3.7 KiB
Poste.io Dockerized Mail Server
Self-hosted, Git-managed mail server for your personal domain using Poste.io.
Last Updated: 1405/01/02 (2026/03/22)
Project Structure
poste-deployment
├── .env.sample
├── .gitignore
├── docker-compose.yml
└── README.md
Setup Instructions
1. Clone & Configure
Clone this repository to your server:
git clone https://git.amiirkhl.ir/interanet/poste-deployment.git /opt/mailserver
cd /opt/mailserver
Create your environment file from the sample:
cp .env.sample .env
Edit .env and ensure MAIL_HOSTNAME and TZ are correct.
2. Custom SSL Configuration
Since Let's Encrypt is disabled (HTTPS=OFF), you must provide your own SSL certificates. This project maps your existing certificates directly into the container.
- Open your
.envfile. - Locate
SSL_CERT_PATHandSSL_KEY_PATH. - Set their values to the absolute paths of your certificate files on the host server (e.g.,
/etc/ssl/amiirkhl.ir/fullchain.pem).
⚠️ CRITICAL DOCKER WARNING: The files specified in SSL_CERT_PATH and SSL_KEY_PATH must exist on your server before you run docker compose up. If Docker cannot find the files, it will mistakenly create empty directories with those names, which will crash the mail server.
3. Start the Server
Start the Docker container:
docker compose up -d
Once running, navigate to https://mail.amiirkhl.ir to access the Admin GUI and set your master admin password.
DNS Configuration Guide
To ensure your emails do not go to the spam folder, configure the following records in your DNS management panel (Cloudflare, ArvanCloud, etc.).
⚠️ Important: Ensure any Proxy/CDN settings (like Cloudflare's orange cloud) are turned OFF (DNS Only) for these records.
| Type | Name / Host | Value / Target | Priority |
|---|---|---|---|
| A | mail |
<Your-Server-IP> |
- |
| MX | @ |
mail.amiirkhl.ir |
10 |
| TXT | @ |
v=spf1 mx a:mail.amiirkhl.ir ~all |
- |
| TXT | _dmarc |
v=DMARC1; p=quarantine; rua=mailto:admin@amiirkhl.ir |
- |
DKIM Setup
DKIM adds a cryptographic signature to your emails.
- Log into the Poste.io Admin Panel (
https://mail.amiirkhl.ir). - Navigate to Virtual domains -> Click on
amiirkhl.ir. - Locate the DKIM key section.
- Click "Generate new key" (if not already generated).
- Copy the provided TXT record and add it to your DNS panel. Usually, the Name is
s1._domainkeyand the Value isv=DKIM1; k=rsa; p=....
Data Persistence & Backups
All user data, emails, databases, and configuration overrides are stored inside the ./data folder.
Automated Backups
This project includes a script to automate backups of your ./data directory based on your .env configuration.
-
Ensure the backup variables are set in your
.envfile:ENABLE_BACKUPS=TRUEBACKUP_CRON="0 2 * * *"(Sets the schedule, e.g., daily at2AM)BACKUP_RETENTION_DAYS=7(Deletes backups older than7days)
-
Make the setup script executable and run it:
chmod +x setup_backup.sh ./setup_backup.sh
The script will automatically register a cron job on your host machine. Backups will be securely compressed as .tar.gz files and stored in the newly created ./backups directory. Old backups are automatically pruned based on your retention settings.
Manual Backup
If you prefer to trigger a backup manually at any time without using the script, simply run:
tar -czvf mail_backup_$(date +%F).tar.gz ./data/