“550 5.7.1 中继被拒绝”通过 Mailgun 使用 msmtp 发送

"550 5.7.1 Relaying denied" sending via Mailgun with msmtp

有人成功地使用 Mailgun 帐户设置了 msmtp 吗?我一直收到“中继被拒绝”的消息,并且 msmtp 报告来自的信封无效。我已经尝试了我能想到的发件人地址的所有变体,搜索了 Mailgun 的文档以获取有关其 SMTP 参数的详细信息,并在网络上搜索了示例,但我没有发现任何与我的设置不同的地方(除了服务器和帐户当然是名字)。

这是我的 /etc/msmtprc 文件,

account default

# The SMTP smarthost
host smtp.mailgun.org

# Use TLS on port 465
port 465
tls on
tls_starttls off

user manul@mail.mydomain.net
password [snip]

from mailgun@mydomain.net

# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL

和 msmtp 会话:

$ echo 'Subject: Grfg' | msmtp -v 'aidalgol@example.net'
loaded system configuration file /etc/msmtprc
ignoring user configuration file /home/me/.msmtprc: No such file or directory
falling back to default account
using account default from /etc/msmtprc
host = smtp.mailgun.org 
port = 465
source ip = (not set)   
proxy host = (not set)  
proxy port = 0
timeout = off
protocol = smtp
domain = localhost
auth = none
user = manul@mail.mydomain.net
password = *
passwordeval = (not set)
ntlmdomain = (not set)
tls = on
tls_starttls = off
tls_trust_file = system
tls_crl_file = (not set)
tls_fingerprint = (not set)
tls_key_file = (not set)
tls_cert_file = (not set)
tls_certcheck = on
tls_min_dh_prime_bits = (not set)
tls_priorities = (not set)
auto_from = off
maildomain = (not set)
from = mailgun@aidalgolland.net
add_missing_from_header = on
add_missing_date_header = on
remove_bcc_headers = on
dsn_notify = (not set)
dsn_return = (not set)
logfile = (not set)
logfile_time_format = (not set)
syslog = LOG_MAIL
aliases = (not set)
reading recipients from the command line
TLS session parameters:
    (TLS1.3)-(ECDHE-X25519)-(RSA-PSS-RSAE-SHA256)-(AES-128-GCM)
TLS certificate information:
    Owner:
        Common Name: *.mailgun.org
        Organization: MAILGUN TECHNOLOGIES\, INC
        Organizational unit: MAILGUN TECHNOLOGIES\, INC
        Locality: San Francisco
        State or Province: California
        Country: US
    Issuer:
        Common Name: Thawte TLS RSA CA G1
        Organization: DigiCert Inc
        Organizational unit: www.digicert.com
        Country: US
    Validity:
        Activation time: Wed 19 Feb 2020 13:00:00 NZDT
        Expiration time: Wed 20 Apr 2022 00:00:00 NZST
    Fingerprints:
        SHA256: 9E:5F:9B:27:BB:26:14:6F:3E:2F:50:75:FE:BF:64:1C:4B:8D:E0:A6:B7:EA:4F:27:13:05:FD:81:3F:57:52:26
        SHA1 (deprecated): 54:36:F6:D1:44:0A:B4:62:F0:94:1B:21:7A:1B:82:5C:DF:FD:FF:57
<-- 220 Mailgun Influx ready
--> EHLO localhost
<-- 250-smtp-out-n17.prod.us-east-1.postgun.com
<-- 250-AUTH PLAIN LOGIN
<-- 250-SIZE 52428800
<-- 250-8BITMIME
<-- 250-ENHANCEDSTATUSCODES
<-- 250-SMTPUTF8
<-- 250 PIPELINING
--> MAIL FROM:<mailgun@myexample.net>
--> RCPT TO:<aidalgol@example.net>
--> DATA
<-- 550 5.7.1 Relaying denied
msmtp: envelope from address mailgun@mydomain.net not accepted by the server
msmtp: server message: 550 5.7.1 Relaying denied
msmtp: could not send mail (account default from /etc/msmtprc)

原来是我需要在msmtp配置中设置auth on。来自 msmtp 的错误 envelope from address mailgun@mydomain.net not accepted by the server 是完全错误的。