Closed2

Postfix:SendGridへのリレー設定

rhenerhene

relayhost およびSMTP認証有効化

mail.cf の修正し、relayhost の設定とSMTP認証を有効化する。

/etc/postfix/main.cf
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_tls_security_level = encrypt
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587

SMTP認証設定

/etc/postfix/sasl_passwd を新規作成して、認証情報を作成する。
ユーザ名は apikey とし、パスワードはAPIキーを指定する。

/etc/postfix/sasl_passwd
[smtp.sendgrid.net]:587 apikey:your_apikey

下記コマンドを実行し、sasl_passwd.db を作成する。

chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd

Postfixの再起動

systemctl restart postfix
rhenerhene

no mechanism available エラーでメールが送信できない場合

SASL認証ライブラリを追加する。

# ubuntuなど場合
apt-get install libsasl2-modules

# CentOSなどの場合
yum install cyrus-sasl-plain

# postfixの再起動
systemctl restart postfix

# キューの再送信
postqueue -f
このスクラップは2021/08/18にクローズされました