目錄表

安裝設定 Mailu 郵件主機(Docker)

如果要使用 Let's Encrypt 免費憑證必須要
  1. DNS 內 A Record 需要有 hostname 並指向 Mail Server 的 IP Exp. mail01.ichiayi.com → 45.76.145.111
  2. hostname 就是 Mail Server 名稱 Exp. mail01.ichiayi.com

安裝程序

  1. 開啟主機防火牆

    ufw allow proto tcp from any to any port 25,80,110,143,443,465,587,993,995 comment 'Open SSH/Web/Mail ports'
    ufw allow proto udp from any to any port 161 comment 'Open SNMP ports'

  2. 使用 https://setup.mailu.io/2024.06/ 產生設定檔
    1. Version : 2024.06
    2. Step1:
      1. Mailu storage path: /mailu
      2. Main mail domain and server display name. : mail01.ichiayi.com
      3. Postmaster local part : admin
      4. TLS certificates : letsencrypt
      5. Authentication rate limit per IP for failed login : 5 /hour
      6. Authentication rate limit per user : 50 /day
      7. Outgoing message rate limit (per user) : 5000 /day
      8. Website name : mail01 for ichiayi.com
      9. Linked Website URL : https://www.ichiayi.com
      10. Enable the admin UI : [V]
    3. Step 2 - Pick some features
      1. Enable Web email client : none
      2. Enable oletools : [ ]
    4. Step 3 - expose Mailu to the world
      1. IPv4 listen address : 0.0.0.0
      2. Subnet of the docker network : 192.168.203.0/24
      3. Enable an internal DNS resolver (unbound) [V]
      4. Public hostnames : mail01.ichiayi.com
  3. 依照 https://setup.mailu.io/2024.06/ 建議執行
    1. Step 1 - Download your configuration files

      mkdir /mailu
      cd /mailu
      wget https://setup.mailu.io/2024.06/file/0827c1b0-1fad-479d-xxxx-23a71d37744f/docker-compose.yml
      wget https://setup.mailu.io/2024.06/file/0827c1b0-1fad-479d-xxxx-23a71d37744f/mailu.env

    2. Step 2 - Review the configuration : 確認 docker-compose.yml 與 mailu.env 內容是否正常
    3. Step 3 - Start the Compose project

      cd /mailu
      docker compose -p mailu up -d

    • 等啟動 MailU 服務後, 設定管理者密碼 Exp. My_12345Password

      docker compose -p mailu exec admin flask mailu admin admin mail01.ichiayi.com 'My_12345Password'

    • 連上 Web 管理介面 https://mail01.ichiayi.com/admin
      • Administration → Mail domains → Actions → Details 可以看到 DNS SPF entries / DNS TLSA entry / DNS client auto-configuration entries 的設定資訊

Mailu 管理介面 - Antispam

Mailu 更版升級

常見問題

  1. postfix 紀錄出現 Sender address rejected: not owned by user 無法寄出信件問題
    • 只要在管理介面將寄信者帳號的 Allow the user to spoof the sender (send email as anyone) 打勾即可
    • Administration → Mail domain → Manage → Users → Actions → Edit
  2. 寄信錯誤訊息出現 4.2.1 : SASL login name rejected: You are sending too many emails too fast.
    • Mailu 預設每個用戶每日寄信上限為 200 封, 超過就會出現這訊息
    • 可以透過修改 mailu.env 內的 MESSAGE_RATELIMIT 數值或是將寄信帳號加入 MESSAGE_RATELIMIT_EXEMPTION
    • 重啟 docker compose 來讓新的設定生效

  • 2.0.20(2023/08/16) ghcr.io/mailu/dovecot:2.0 → mailu-imap-1 在主機端只有 ipv4 會無法正常運作
  • 可參考 https://github.com/Mailu/Mailu/issues/2913 在 /mailu/overrides/dovecot/ 目錄內產生 dovecot.conf 檔案內容

    listen = *

    docker compose 重啟 smtp 服務即可解決

參考網址