构建基于docker-compose的邮件系统
1. 配置域名 @ 记录指向邮件服务器ip
2. 建立目录: /data0/Server/Settings/docker-mailserver
3. 获取需要的脚本
cd /data0/Server/Settings/docker-mailserver
wget https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master/docker-compose.yml
wget https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master/mailserver.env
# if you're using :edge as the image tag
wget https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master/setup.sh
chmod a+x ./setup.sh
# and make yourself familiar with the script
./setup.sh help
4. 修改mailserver.env,启用pop3
# 1 => Enables POP3 service
# empty => disables POP3
ENABLE_POP3=1
ENABLE_CLAMAV=0
5. 修改 docker-compose.yml 内容为合适路径(注意目录权限)
version: '3.8'
services:
mailserver:
image: docker.io/mailserver/docker-mailserver:latest
hostname: mail
domainname: mkplay.xyz
container_name: mailserver
env_file: mailserver.env
# To avoid conflicts with yaml base-60 float, DO NOT remove the quotation marks.
# More information about the mailserver ports:
# https://docker-mailserver.github.io/docker-mailserver/edge/config/security/understanding-the-ports/
ports:
- "25:25" # SMTP (explicit TLS => STARTTLS)
- "110:110" # POP3
- "143:143" # IMAP4 (explicit TLS => STARTTLS)
- "465:465" # ESMTP (implicit TLS)
- "587:587" # ESMTP (explicit TLS => STARTTLS)
- "993:993" # IMAP4 (implicit TLS)
volumes:
- "/data0/Server/Db/mail:/var/mail"
- "/data0/Server/Var/mail-state:/var/mail-state"
- "/data0/Server/Logs/mail:/var/log/mail"
- "/etc/localtime:/etc/localtime:ro"
- "./config/:/tmp/docker-mailserver/"
restart: always
stop_grace_period: 1m
cap_add: [ "NET_ADMIN", "SYS_PTRACE" ]
6. 试运行
docker-compose up -d mailserver
./setup.sh email add <user@domain> [<password>]
./setup.sh alias add postmaster@<domain> <user@domain>
./setup.sh config dkim
7. 完成