自前のメールサーバーがあるといろんなことができて便利です。
CentOSでは最初にsendmailがインストールされています。Postfixをインストールして、MTAを変更します。
# yum install postfix # alternatives --config mta 2 プログラムがあり 'mta' を提供します。 選択 コマンド ----------------------------------------------- + 1 /usr/sbin/sendmail.postfix * 2 /usr/sbin/sendmail.sendmail Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:1 # yum remove sendmail
myhostname = thaliana.myhome.cx mydomain = thaliana.myhome.cx myorigin = $myhostname inet_interfaces = all relay_domains = $mydestination home_mailbox = Maildir/ mailbox_command = /usr/bin/procmail # プロバイダー経由でメールを送信する relayhost = [mail.x.x.xxx]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/smtpauth # ファイルを作成(後述) smtp_sasl_tls_security_options = noanonymous smtp_tls_policy_maps = hash:/etc/postfix/tls_policy # ファイルを作成(後述) # SMTP認証設定 (smtp-auth) smtpd_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination # SSL/TLS (smtps)用設定 smtpd_use_tls = yes smtpd_tls_cert_file = /etc/pki/tls/certs/thaliana.myhome.cx.crt smtpd_tls_key_file = /etc/pki/tls/private/thaliana.myhome.cx.key smtpd_tls_loglevel = 1 # mailman用設定 alias_maps = hash:/etc/aliases, hash:/etc/mailman/aliases recipient_delimiter = + owner_request_special = no
メールの発信に信用あるプロバイダーのサーバーを使用するための設定を行う。
[mail.x.x.xxx]:587 account:password
# postmap hash:/etc/postfix/smtpauth
[mail.x.x.xxx]:587 encrypt
# postmap hash:/etc/postfix/tls_policy
root宛てのメールがサーバー管理者に届くようにする。
root: takamasa
待ち受けポートの設定をする。 submissionは587番ポートでOutbound Port 25 Blockを回避するために使われる。 個人用であればどちらかで十分です(メールクライアントの設定が必要)。
# 以下の行の先頭の#をとる submission inet n - n - - smtpd -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes main.cfにあるのでこれはいらないかも -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes main.cfにあるのでこれはいらないかも -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING
# service postfix restart # chkconfig postfix on
第三者中継チェックを利用して、メールサーバーが踏み台にされないかどうかチェックする。
procmailがMaildirにメールを配送するように設定します。
新しく作成するユーザーのホームディレクトリに自動的にMaildirが作成されるようにします。
# mkdir -p /etc/skel/Maildir/{new,cur,tmp} # chmod 700 /etc/skel/Maildir/