我一直在嘗試使用 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 上,我的 /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