先日、muttコマンドでメール送信の記事を記載しました。
この時はTLSをOFFにしてたのですが、折角なのでTLSで送信してみました。
調べながら試行錯誤したところ何とか送信できるようになりました。
- 設定ファイル
- テストメール
- ログの確認
TLS用設定ファイルを作成します。ファイル名は適当に。
1 2 3 4 5 6 7 8 9 10 11 |
[root@centos8 ~]# vi /etc/Muttrc.tls [root@centos8 ~]# cat /etc/Muttrc.tls # Local configuration for Mutt. set my_pass=Passwrod123 set my_user=guest01 set realname="Guesr01" set from="guest01@example.co.jp" set smtp_url=smtps://$my_user:$my_pass@mail.example.co.jp set ssl_starttls=yes |
デバックモードで送信テスト
1 2 |
[root@centos8 ~]# echo Alert | mutt -d 3 -F /etc/Muttrc.tls -s "Alert message" alert-mail@example.co.jp Debugging at level 3. |
送信OK
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
[root@centos8 ~]# cat .muttdebug0 [2020-12-02 17:52:07] Mutt/1.10.1 (2018-07-13) debugging at level 3 [2020-12-02 17:52:07] getdnsdomainname(): example.co.jp [2020-12-02 17:52:07] Reading configuration file '/etc/Muttrc'. [2020-12-02 17:52:07] Reading configuration file '/etc/Muttrc.local'. [2020-12-02 17:52:07] Reading configuration file '/etc/Muttrc.tls'. [2020-12-02 17:52:07] send.c:1273: mutt_mktemp returns "/tmp/mutt-centos8-0-2147-44444". [2020-12-02 17:52:07] sendlib.c:2790: mutt_mktemp returns "/tmp/mutt-centos8-0-55555555". [2020-12-02 17:52:07] send.c:987: mutt_mktemp returns "/tmp/mutt-centos8-0-2147-666". [2020-12-02 17:52:07] Connected to mail.example.co.jp:465 on fd=6 [2020-12-02 17:52:07] 6< 220 mail.example.co.jp ESMTP [2020-12-02 17:52:07] 6> EHLO centos8.example.co.jp [2020-12-02 17:52:07] 6< 250-mail.example.co.jp [2020-12-02 17:52:07] 6< 250-PIPELINING [2020-12-02 17:52:07] 6< 250-SIZE 20480000 [2020-12-02 17:52:07] 6< 250-ETRN [2020-12-02 17:52:07] 6< 250-AUTH PLAIN LOGIN [2020-12-02 17:52:07] 6< 250-AUTH=PLAIN LOGIN [2020-12-02 17:52:07] 6< 250-ENHANCEDSTATUSCODES [2020-12-02 17:52:07] 6< 250-8BITMIME [2020-12-02 17:52:07] 6< 250 DSN [2020-12-02 17:52:07] SASL local ip: 192.168.1.1;46222, remote ip:192.168.1.2 [2020-12-02 17:52:07] External SSF: 256 [2020-12-02 17:52:07] External authentication name: guest01 [2020-12-02 17:52:07] 6> AUTH LOGIN [2020-12-02 17:52:07] 6< 334 vxN2Cm5AbWU5 [2020-12-02 17:52:07] mutt_sasl_cb_authname: getting authname for mail.example.co.jp [2020-12-02 17:52:07] 6> Bwf5C3vva4e= [2020-12-02 17:52:07] 6< 334 uAVZcAdvTm02 [2020-12-02 17:52:07] mutt_sasl_cb_pass: getting password for guest01@mail.example.co.jp [2020-12-02 17:52:07] 6> YwFzD45v1T9tA9== [2020-12-02 17:52:07] 6< 235 2.7.0 Authentication successful [2020-12-02 17:52:07] SASL protection strength: 0 [2020-12-02 17:52:07] SASL protection buffer size: 65536 [2020-12-02 17:52:07] 6> MAIL FROM:<guest01@example.co.jp> [2020-12-02 17:52:07] 6< 250 2.1.0 Ok [2020-12-02 17:52:07] 6> RCPT TO:<alert-mail@example.co.jp> [2020-12-02 17:52:07] 6< 250 2.1.5 Ok [2020-12-02 17:52:07] 6> DATA [2020-12-02 17:52:07] 6< 354 End data with <CR><LF>.<CR><LF> [2020-12-02 17:52:07] 6> . [2020-12-02 17:52:07] 6< 250 2.0.0 Ok: queued as 657A062B4B [2020-12-02 17:52:07] 6> QUIT [2020-12-02 17:52:07] mutt_free_body: unlinking /tmp/mutt-centos8-0-2147-4444444 |
届いたメールのヘッダ確認
1 2 |
Received: from centos8.example.co.jp (unknown) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) |