通过 telnet SMTP 发送电子邮件

通过 telnet SMTP 发送电子邮件

当我连接到 Gmail 的一个 SMTP 服务器(通过 Windows cmd)后,当我尝试

sending mail to myself, it keeps giving me the same error.

220 mx.google.com ESMTP u3si16129057wmg.22 - gsmtp
ehlo b
250-mx.google.com at your service, [2607:fcd8:a:5:426d:e920:51f3:f36e]
250-SIZE 157286400
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
MAIL FROM: <[email protected]>
250 2.1.0 OK u3si16129057wmg.22 - gsmtp
RCPT TO: <[email protected]>
250 2.1.5 OK u3si16129057wmg.22 - gsmtp
DATA
354  Go ahead u3si16129057wmg.22 - gsmtp
SOMETHING SOMETHING SOMETHING.

.
550-5.7.1 [2607:fcd8:a:5:426d:e920:51f3:f36e      11] Our system has detected
550-5.7.1 that this message is not RFC 5322 compliant. To reduce the amount of
550-5.7.1 spam sent to Gmail, this message has been blocked. Please review
550 5.7.1  RFC 5322 specifications for more information. u3si16129057wmg.22 - gs
mtp


Connection to host lost.

Press any key to continue...

我查阅了 RFC 5322 并尝试了以下操作

220 mx.google.com ESMTP bo10si34007895wjb.163 - gsmtp
ehlo b
250-mx.google.com at your service, [2607:fcd8:a:5:426d:e920:51f3:f36e]
250-SIZE 157286400
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
MAIL FROM: <[email protected]> CRLF
250 2.1.0 OK bo10si34007895wjb.163 - gsmtp
RCPT TO: <[email protected]> CRLF
250 2.1.5 OK bo10si34007895wjb.163 - gsmtp
DATA CRLF
354  Go ahead bo10si34007895wjb.163 - gsmtp
something something something. CRLF
. crlf
. CRLF
.
550-5.7.1 [2607:fcd8:a:5:426d:e920:51f3:f36e      11] Our system has detected
550-5.7.1 that this message is not RFC 5322 compliant. To reduce the amount of
550-5.7.1 spam sent to Gmail, this message has been blocked. Please review
550 5.7.1  RFC 5322 specifications for more information. bo10si34007895wjb.163 -
 gsmtp


Connection to host lost.

任何帮助都将不胜感激!

答案1

我只能猜测原作者的理由,但作为托管公司的系统管理员,我经常使用它来调试邮件问题。该过程很简单,在很多地方都有描述,例如https://dougrathbone.com/blog/2010/02/17/manually-testing-smtp-mail-issues-via-telnet

问题在于 Google 对 RFC 5322 的解释有些宽泛,要求在数据后添加一个额外的“发件人:”字段,例如:

$ telnet gmail-smtp-in.l.google.com. 25
Trying 173.194.222.27...
Connected to gmail-smtp-in.l.google.com (173.194.222.27).
Escape character is '^]'.
220 mx.google.com ESMTP j6si1491418lja.259 - gsmtp
HELO yourhost.com
250 mx.google.com at your service
mail from: <[email protected]>
250 2.1.0 OK j6si1491418lja.259 - gsmtp
rcpt to: <[email protected]>
250 2.1.5 OK j6si1491418lja.259 - gsmtp
data
354  Go ahead j6si1491418lja.259 - gsmtp
From: [email protected]
Subject: test, please ignore
test, please ignore
.
250 2.0.0 OK  1571305610 j6si1491418lja.259 - gsmtp
quit
221 2.0.0 closing connection j6si1491418lja.259 - gsmtp
Connection closed by foreign host.

答案2

执行命令后,DATA需要/预期收到格式正确的电子邮件信息。

RFC 5322定义标准,定义如何“格式正确的消息”应该看看。

消息由报头字段(统称为“消息的报头部分”)组成,后面可以有正文(可选)。报头部分是一系列字符,具有本规范中定义的特殊语法。
正文只是一系列字符,位于报头部分之后,由空行(即 CRLF 之前没有任何内容的行)与报头部分分隔开。

获取此类消息的快捷方式是:大多数电子邮件客户端允许您查看现有电子邮件的原始消息格式。复制并粘贴。

相关内容