構成

構成

msmtpでメールを送信しようとしましたが、成功しませんでした

設定ファイル: ~/.msmtprc

defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
logfile        ~/.msmtp.log

account iisr
host smtp.yandex.com
port 465
user [email protected]
from [email protected]
password ********

コマンドでテストすると、ログファイルにも結果が全く表示されません。echo "hello there username." | msmtp -a iisr [email protected]

以下の回答にある @Andrezj のスクリプトを使用すると、次の出力が得られ、次のようになります。

ignoring system configuration file /etc/msmtprc: No such file or directory
loaded user configuration file /home/bakenoor/.msmtprc
using account iisr from /home/bakenoor/.msmtprc
host                  = smtp.yandex.com
port                  = 465
timeout               = off
protocol              = smtp
domain                = localhost
auth                  = choose
user                  = [email protected]
password              = *
passwordeval          = (not set)
ntlmdomain            = (not set)
tls                   = on
tls_starttls          = on
tls_trust_file        = /etc/ssl/certs/ca-bundle.crt
tls_crl_file          = (not set)
tls_fingerprint       = (not set)
tls_key_file          = (not set)
tls_cert_file         = (not set)
tls_certcheck         = on
tls_force_sslv3       = off
tls_min_dh_prime_bits = (not set)
tls_priorities        = (not set)
auto_from             = off
maildomain            = (not set)
from                  = [email protected]
dsn_notify            = (not set)
dsn_return            = (not set)
keepbcc               = off
logfile               = /home/bakenoor/.msmtp.log
syslog                = (not set)
aliases               = (not set)
reading recipients from the command line and the mail

メールが送信されない理由をご存知ですか?

答え1

構成

SMTPポート465の場合は、TLS開始オプションがオンになっていることを確認してください。オフファイル内$HOME/.msmtprc:

defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        /tmp/msmtp.log

account        ACCOUNT
host           mail.host.com
port           465
from           [email protected]
user           [email protected]
password       PASSWORD
tls_starttls   off

account default : ACCOUNT

また、ファイルの権限がユーザーに制限されていることを確認します。

chmod 600 $HOME/.msmtprc

msmtp メール送信のデバッグ

SMTPセッションの完全なトランスクリプトを取得するには、次のテストスクリプトを使用します。

#!/bin/sh
# msmtp specific options
# -d : debug
# -a : account name
# sendmail compatibility options
# -i : ignored for sendmail capability
# -t : Read recipient addresses from the To, Cc, and Bcc headers 
msmtp -d -a iisr -i -t <<END
From: [email protected]
To: [email protected]
Subject: test

test
END

関連している

詳細については、以下を参照してください。

答え2

ファイアウォールの背後にある CentOS 7.3 では、My /etc/msmtprc:

defaults
logfile /var/log/msmtp.log
domain localhost
auth on
port 465
host smtp.gmail.com
tls on
tls_starttls off
auth on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
# gmail account
account workflow
user *[email protected]*
from *[email protected]*
password *mypassword*
# set default account to use
account default : workflow

関連情報