====== PostfixからGmailへのリレー設定 ====== PostfixからGmailへのメールリレー設定のメモ ===== Googleのアプリパスワードの取得 ===== Googleアカウントの管理画面から[[https://support.google.com/accounts/answer/185833?hl=ja|アプリパスワード]]を作成し取得します。 ===== パスワードDBの作成 ===== アプリパスワードをSASLパスワードDBに設定します。 [smtp.gmail.com]:587 username@gmail.com:sqirskhmgkcbvujw ※パスワードは仮のものです。 パスワード設定ファイルを作成します。 $ sudo postmap /etc/postfix/gmail $ ls -ltr /etc/postfix **gmail.db**が生成されたパスワードファイルです。 ===== SASLモジュールの導入 ===== libsasl2-modulesを導入します。 $ apt install libsasl2-modules ===== Postfix設定 ===== **/etc/postfix/main.cf**にSASL設定などを追加します。 myhostname = mail.domain1.jp mydomain = domain1.jp relayhost = [smtp.gmail.com]:587 # Gmail relay smtp_sasl_auth_enable = yes smtp_sasl_mechanism_filter = plain smtp_sasl_password_maps = hash:/etc/postfix/gmail smtp_sasl_security_options = noanonymous smtp_sasl_tls_security_options = noanonymous smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtp_tls_security_level = encrypt smtp_use_tls = yes