Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Last active January 24, 2022 19:39
Show Gist options
  • Save yano3nora/8c6505fb240497a81c5d6fc12c081efa to your computer and use it in GitHub Desktop.
Save yano3nora/8c6505fb240497a81c5d6fc12c081efa to your computer and use it in GitHub Desktop.
[docker: Mail server container] Mail servers by Docker. #docker

MAILHOG

mailhog/MailHog - github.com
mailhog/mailhog - hub.docker.com
MailHogを利用してメール送信テスト環境をdockerコンテナ上に作る

わりとスター数の多い開発用メールサーバ Docker コンテナ。DockerHub で公開されているので Docker 環境でメールの SMTP 送信テストにサクっと利用できる。

# docker-compose.yml
services: 
  mailhog:
    image: mailhog/mailhog
    ports:
      - "8025:8025"  # http://localhost:8025 で GUI で確認可能
      - "1025:1025"  # SMTP 用のポート、メール送信設定にはこっちを指定

DOCKER-MAILSERVER

tomav/docker-mailserver - github.com
tvial/docker-mailserver - hub.docker.com
Docker Compose でサーバを構築する、SMTP+POP3サーバ編

こっちはガチのメールサーバコンテナ。本番環境での利用を想定されていて fail2ban やアンチウィルス/スパム、TLS にも対応している。設定ファイルだけでなんでもできるよ!っていうのがウリみたい。

services:
  mail:
    image: tvial/docker-mailserver:stable
    container_name: mail-server
    domainname: example.com
    ports:
      - "25:25"
      - "110:110"
    volumes:
      - ./.docker/mail/config/:/tmp/docker-mailserver/
    environment:
      # debug したい場合には以下の行のコメントアウトを解除
      # - DMS_DEBUG=1
      - ENABLE_SPAMASSASSIN=0
      - ENABLE_CLAMAV=0
      - ENABLE_FETCHMAIL=0
      - ENABLE_FAIL2BAN=0
      - ENABLE_POSTGREY=0
      - ENABLE_POP3=1
    cap_add:
      - NET_ADMIN
      - SYS_PTRACE
    restart: always
# .docker/mail/config/postfix-accounts.cf
user@example.com|{PLAIN}your-password-here

# .docker/mail/config/postfix-main.cf
mydestination =
smtpd_recipient_restrictions =

# .docker/mail/config/dovecot.cf
disable_plaintext_auth = no
ssl = no
# debug したい場合には以下の行のコメントアウトを解除
# auth_verbose = yes
# auth_debug = yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment