通过msmtp发送邮件

Noo*_*oor 6 email smtp msmtp

我一直在尝试使用 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 info@iisr.mu
from info@iisr.mu
password ********
Run Code Online (Sandbox Code Playgroud)

使用命令测试时echo "hello there username." | msmtp -a iisr noorani.bakerally@gmail.com,根本没有结果,也没有在日志文件中,

在下面的答案中使用@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                  = info@iisr.mu
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                  = info@iisr.mu
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
Run Code Online (Sandbox Code Playgroud)

知道为什么没有发送邮件吗?

小智 5

配置

对于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           account@host.com
user           account@host.com
password       PASSWORD
tls_starttls   off

account default : ACCOUNT
Run Code Online (Sandbox Code Playgroud)

还要确保文件权限仅限于用户:

chmod 600 $HOME/.msmtprc
Run Code Online (Sandbox Code Playgroud)

调试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: info@iisr.mu
To: info@iisr.mu
Subject: test

test
END
Run Code Online (Sandbox Code Playgroud)

有关的

有关详细信息,请参阅以下内容: