ラベル gmail の投稿を表示しています。 すべての投稿を表示
ラベル gmail の投稿を表示しています。 すべての投稿を表示

2018年9月23日日曜日

メール送信システム ( postfix, mail ) インストールとgmailリレー送信設定

2018 Sep. 23.

こちらのページは無視してよい。

( https://blog.ymyzk.com/2017/06/postfix-smarthost-gmail/ より)

gmailアカウント

2段階認証プロセス:オフ
安全性の低いアプリの許可:有効

パッケージインストール


# apt install postfix bsd-mailx libsasl2-modules
  postfix設定問い合わせでは、Internet with smarthost を選択し、
  ”SMTP relay host” には [smtp.gmail.com]:587 を記述する

設定

/etc/postfix/sasl_passwd を次の1行の内容で作成する

[smtp.gmail.com]:587 gmailアカウント@gmail.com:パスワード
: をアカウントとパスワードで挟んだ書式)

# cd /etc/postfix
# chmod 600 sasl_passwd
# postmap /etc/postfix/sasl_passwd
 
/etc/postfix/main.cf に次の4行を追記する

smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_tls_security_options = noanonymous
 

postfix再起動

# systemctl restart postfix.service
 

メール送信

$ Msg="読めますか?\n2行目です。\n3行目です"
$ Title='メール試験'
$ MailDest="hoo@example.xx bar@example.yy"
$ echo -e "${Msg}" | mail -s `echo -e "${Title}" | nkf -jM` $MailDest
 
(下記のように本文をjisコードにすると文字化けした) 
$ echo -e "${Msg}" | nkf -j  | mail -s `echo -e "${Title}" | nkf -jM` $MailDest


確認

# tail -f /var/log/mail.log

2017年8月20日日曜日

postfix設定

2018 Sep. 23.
2017 Aug. 20.

このページは無視して、こちらを参照すればよい。


myhostname = gmeil.com, mydomain = gmail.com と設定したら、gmailへのメールが届かな
い。
no-ipで取得しているドメイン名にしたらgmailへのメールが届いた。
設定後、 # systemctl restart postfix.service。
# systemctl restart postfix ではだめのよう。



[/etc/postfix/main.cf]

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = xxxx.no-ip.info
mydomain = xxxx.no-ip.info
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 192.168.1.0/24
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
smtp_helo_name = $myhostname
smtp_sasl_auth_enable = yes
smtp_sasl_mechanism_filter = plain
smtp_sasl_password_maps = hash:/etc/postfix/gmail_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_use_tls = yes
smtp_tls_CApath = /etc/ssl/certs/ca-certificates.crt