!

Mar 31 Wed. 2021

メール送信設定

Mailbox USA.jpg

Tony Teaches Tech

設定ファイルにサーバ名とパスワードを記載

$ sudo vi /etc/postfix/sasl/sasl_password
[smtp.gmail.com]:587 xxx@gmail.com:lmNov5XVs7DfYB
$ sudo postmap /etc/postfix/sasl/sasl_password
$ ls /etc/postfix/
sasl_password sasl_password.db
$ sudo chown -v root:root /etc/postfix/sasl/*
$ sudo chmod -v 600       /etc/postfix/sasl/*

設定ファイルに SASL の設定を追加

$ sudo vi /etc/postfix/main.cf
# relayhost = 
relayhost = [smtp.gmail.com]:587
# Enable SASL
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_password
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

再起動

$ sudo systemctl restart postfix

コマンドラインからメール送信

$ sendmail destination@example.com
From: origination@example.org
Subject: This is mail #1
This is the mail body.
^D