你好,我尝试使用 sendmail 从我的 centos 终端发送电子邮件,但它不起作用,我使用默认配置的命令,因为我只想发送电子邮件。我需要帮助。接下来我使用[电子邮件保护],这将是我想要发送电子邮件的真正的 Gmail 用户。我所做的是:
[root@localhost ~]# echo "Subject: sendmail test gmail" | sendmail -v [email protected]
[email protected]... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Fri, 3 Jun 2016 16:56:01 -0300
>>> EHLO localhost.localdomain 250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-DELIVERBY 250 HELP
>>> MAIL From:<[email protected]> SIZE=29 250 2.1.0 <[email protected]>... Sender ok
>>> RCPT To:<[email protected]>
>>> DATA 250 2.1.5 <[email protected]>... Recipient ok 354 Enter mail, end with "." on a line by itself
>>> . 250 2.0.0 u53Ju1vI022862 Message accepted for delivery [email protected]... Sent (u53Ju1vI022862 Message accepted for delivery) Closing connection to [127.0.0.1]
>>> QUIT 221 2.0.0 localhost.localdomain closing connection
但是 gmail 收不到邮件,而且我在日志中看到 verify=fail。/var/log/maillog 显示:
Jun 3 16:56:01 localhost sendmail[22861]: u53Ju13j022861: from=root, size=29, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Jun 3 16:56:01 localhost sendmail[22862]: u53Ju1vI022862: from=<[email protected]>, size=330, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Jun 3 16:56:01 localhost sendmail[22861]: u53Ju13j022861: [email protected], ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30029, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (u53Ju1vI022862 Message accepted for delivery)
Jun 3 16:56:03 localhost sendmail[22864]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=AES128-SHA, bits=128/128
Jun 3 16:56:04 localhost sendmail[22864]: u53Ju1vI022862: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:03, xdelay=00:00:03, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. [64.233.186.27], dsn=2.0.0, stat=Sent (OK 1464983764 l40si4464056qtc.52 - gsmtp)
答案1
邮件实际上已被 gmail 端接受。最后一行显示了这一点,您会从接收服务器收到以下内容:OK 1464983764 l40si4464056qtc.52 - gsmtp
verify=fail 与 TLS 协商有关(我认为客户端证书验证失败,这通常不会强制执行)。
我首先想到的是,您的邮件可能会被丢弃,或者至少根据您的发件人地址被添加为垃圾邮件。此外,如果您的服务器没有配置 PTR 记录,则服务器无法进行反向查找以验证您是发件人,这也可能会将其标记为垃圾邮件/非合法邮件。
首先尝试指定一个有效的发件人/发件人地址,看看是否允许它到达。