MAMP mailサーバー設定-忘備録
postfixにてメールを送付
公式サイト
参考にさせていただきました。 https://joyplot.com/documents/2016/11/07/postfix-send-mail/
Postfix とは MTA(Message Transfer Agent) と呼ばれる、電子メールを扱うソフトウェアのこと。macOS には標準で Postfix がインストールされている
mail.cfのパス Postfixの設定ファイル
/etc/postfix/main.cf
SASLを設定 グーグルの2段階認証の為
SASL(Simple Authentication and Security Layer)によるSMTP認証を使用するため、main.cf の最後に追記。
#mail for MAMP myorigin = gmail.com myhostname = smtp.gmail.com relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes //このファイル名で読み込むファイルを決定している。 smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_sasl_mechanism_filter = plain smtp_use_tls = yes smtp_tls_security_level=encrypt tls_random_source=dev:/dev/urandom
postmap コマンドにてdbファイルを生成
これが、ハッシュ化されたDBで、転送経路などが記載されているものを作成 処理速度が通常のファイルより早い。
//transportはファイル名 //上記設定で設定したファイル名を利用 postmap authinfo
postfixを再起動
sudo postfix reload
メール送信テスト
date | mail test@gmail.com
DNSのチェック
dig localhost
メールの確認
mailq
失敗したメールを確認できる。 成功していれば、表示されない
ログ確認 MACのみ
log stream --predicate '(process == "smtpd") || (process == "smtp")' --info