Postfix で Gmail を relayhost にする (Ubuntu)
前回は、CentOS 用の設定を書いたのですが、個人的には、Ubuntu を触ることのほうが多いので、設定方法をメモしておきます。
あらかじめ、MTA を postfix に変更済と想定。
- 必要なパッケージをインストール。
$ sudo apt-get install sasl2-bin - postfix の設定ファイルを編集
$ sudo vi /etc/postfix/main.cf - 以下の内容を追記
relayhost = [smtp.gmail.com]:587
#sasl setting
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
#tls setting
smtp_use_tls = yes - /etc/postfix/sasl_passwd を作成(メールアドレスやパスワードは各自のものを)
vi /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 username@gmail.com:password - /etc/postfix/sasl_passwd の権限変更
# chown root:root /etc/postfix/sasl_passwd
# chmod 600 /etc/postfix/sasl_passwd - hash形式の /etc/postfix/sasl_passwd.dbを作成
# postmap /etc/postfix/sasl_passwd - postfixの再起動
# /etc/init.d/postfix restart - で、適当に sendmail などでメールを送信してみて確認してみる。