initial commit

This commit is contained in:
2026-03-23 02:53:33 +08:00
commit abd415fff0
5 changed files with 242 additions and 0 deletions

95
README.md Normal file
View File

@@ -0,0 +1,95 @@
# Poste.io Dockerized Mail Server
Self-hosted, Git-managed mail server for your personal domain using [Poste.io](https://poste.io/).
*Last Updated: 1405/01/02 (2026/03/22)*
## Project Structure
```text
poste-deployment
├── .env.sample
├── .gitignore
├── docker-compose.yml
└── README.md
```
## Setup Instructions
### 1. Clone & Configure
Clone this repository to your server:
```bash
git clone https://git.amiirkhl.ir/interanet/poste-deployment.git /opt/mailserver
cd /opt/mailserver
```
Create your environment file from the sample:
```bash
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.
1. Open your `.env` file.
2. Locate `SSL_CERT_PATH` and `SSL_KEY_PATH`.
3. 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:
```bash
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.
1. Log into the Poste.io Admin Panel (`https://mail.amiirkhl.ir`).
2. Navigate to **Virtual domains** -> Click on `amiirkhl.ir`.
3. Locate the **DKIM key** section.
4. Click "Generate new key" (if not already generated).
5. Copy the provided TXT record and add it to your DNS panel. Usually, the Name is `s1._domainkey` and the Value is `v=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.
1. Ensure the backup variables are set in your `.env` file:
- `ENABLE_BACKUPS=TRUE`
- `BACKUP_CRON="0 2 * * *"` (Sets the schedule, e.g., daily at $2$ AM)
- `BACKUP_RETENTION_DAYS=7` (Deletes backups older than $7$ days)
2. Make the setup script executable and run it:
```bash
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:
```bash
tar -czvf mail_backup_$(date +%F).tar.gz ./data/
```