【relayのみ】ムームーメールのsmtpにsmtp_authを使ってrelay送信する

【PR】
※IT系の記事は当方環境での実施内容となるため実施する場合は自己責任でお願いいたします。

RockyLinuxにて実施

やっぱりサーバの状態とかを受け取っておいた方がよいかと外部へのrelay送信のみ設定。
独立した送受信メールサーバの設定ではないです。
例によって自己責任の内容です。

インストール

$dnf install postfix
$dnf install cyrus-*

※多分cyrusのライブラリが必要な感じなので・・・
入れていないと以下のようなエラーが出るかも。

(SASL authentication failed; cannot authenticate to server smtp.muumuu-mail.com[157.7.107.5]: no mechanism available)
warning: SASL authentication failure: No worthy mechs found

cyrus-*入れると、
サービスとしてはsaslauthdが入るっぽいですが、今回の件とは関係ないかも。

main.cf(smtp_auth,tls使用)

main.cfに追記
本当は自分で証明書を用意した方がいいんでしょうね。

relayhost = [smtp.muumuu-mail.com]:587 
smtp_sasl_auth_enable = yes 
smtp_sasl_password_maps = hash:/etc/postfix/relay_password 
smtp_sasl_security_options = noanonymous

※RockyLinuxの標準postfixでは最初から

smtpd_tls_cert_file 
smtpd_tls_key_file 
smtpd_tls_security_level 
smtp_tls_CApath 
smtp_tls_CApath 
smtp_tls_security_level = may

が有効になっている。

CentOS7のデフォルトpostfixなどTLS関連が有効になっていない場合は、

smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt 
smtpd_tls_security_level = may 
smtp_tls_security_level = may 
smtp_tls_loglevel = 1

を追加

メイメイ言ってますが(笑)

smtp_tls_security_level = may 送信先がTLS対応ならTLS通信 なので今回は受信はせずに送信Onlyなのでここが重要ですかね。 
smtpd_tls_security_level = may 送信元のサーバーやメールクライアントがTLS対応ならTLS通信。

一応、両方突っ込んでおこう。
postfix2.3以降は「smtp_use_tls = yes」は使用せずにこちらを使う模様。

relay用パスワードファイル

relay_password

[smtp.muumuu-mail.com]:587 メールアドレス:パスワード
$postmap relay_password

root宛のメールを他のメールアドレスに転送

必要ならば
/etc/aliases
のrootの宛先を変更

root: メールアドレス
$newaliases

postfixを再起動

$systemctrl reload postfix

テスト

$echo test |mail root

で外部アドレスに転送送信されること。

問題あれば

/var/log/maillog

を確認。
失敗してたまったキューは以下のコマンドで一斉削除できます。
キューの全削除

$postsuper -d ALL
postsuper: Deleted: 92 messages

$mailq
Mail queue is empty

 

Setup_Memo

Posted by admin