LoginSignup
4
4

More than 5 years have passed since last update.

メールサーバをチューン

Last updated at Posted at 2013-07-24

※大幅に改訂しました

想定環境

パッケージ管理でインストールできるソフト

  • Postfix2.x
  • Dovecot2.x

基本設定

送受信がSMTP/POPでできるレベル

main.cf
myhostname = hostname.doma.in
mydomain = doma.in
myorigin = $myhostname
mydestination = $myhostname, localhost.$mydomain, $mydomain
relay_domains = $mydestination
home_mailbox = Maildir/
smtpd_banner = $myhostname ESMTP
html_directory = no
/etc/dovecot/10-mail.conf
mail_location = maildir:~/Maildir

基本的な設定。Maildir形式あたりはデファクトスタンダード

TLSの導入

送信サーバは993、受信サーバは995番で送受信できるようにする。ファイアーウォールなどで該当ポートをブロックしていた場合、解除する。
証明書が必要になるので用意する。

main.cf
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/httpd/conf/ssl.crt/server.crt
smtpd_tls_key_file  = /etc/httpd/conf/ssl.key/server.key
master.cf
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes

submission inet n       -       n       -       -       smtpd
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
dovecot.conf
protocols = pop3
ssl = yes
/etc/dovecot/10-master.conf
service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}
/etc/dovecot/10-ssl.conf
ssl_cert = </etc/httpd/conf/ssl.crt/server.crt
ssl_key  = </etc/httpd/conf/ssl.key/server.key

SMTP-SASL認証

SMTP送信時に認証されたユーザ意外は弾く。下記設定では認証ユーザ情報をDBファイルに外置きするsasldb形式とする。(POPは普通にPam認証なので俺は注意すること。)

main.cf
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
/etc/sasl2/smtpd.conf
pwcheck_method: auxprop
mech_list: cram-md5 digest-md5 plain login

SASLDB操作

sasldblistusers2 ユーザ一覧を見る。
saslpasswd2 ユーザの追加・削除

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4