mail smtp data命令

一 背景

探测163的发件服务器smtp.163.com,对于流程中的data命令总是报500 bad syntax 错误,后找资料发现,data有格式要求,“end with <CRLF>.<CRLF> ”, 但尝试 “data  \r\n.\r\n” 仍然失败。

二 telnet流程

代码未走通,先通过telnet尝试,流程如下:

220 163.com Anti-spam GT for Coremail System (163com[20141201])
HELO 163.COM
250 OK
AUTH LOGIN
334 dXNlcm5hbWU6
xxxxxxxxxxxxxxxx       // 163邮箱账号的base64编码
334 UGFzc3dvcmQ6
xxxxxxxxxxxxxxxx     // 账户密码的base64编码
235 Authentication successful
MAIL FROM :<xxxxxx@163.com>  // 发件人邮箱账户
250 Mail OK
rcpt to : <xxxxxxxxxxx@163.com>  // 收件人邮箱账户
250 Mail OK
data
354 End data with <CR><LF>.<CR><LF>  
SUBJECT: hahahahahahah     // 发送邮件主题
.   // 邮件编辑结束符
250 Mail OK queued as smtp12,EMCowACnrlbF94RblO5eDg--.15992S3 1535441150

发现data命令直接回车后能够正确返回354.

于是将代码改为“data\r\n” ,通过。

三 RFC5321说明

查看rfc5321中data命令的相关说明:

……

The mail data are terminated by a line containing only a period, thatis, the character sequence "<CRLF>.<CRLF>", where the first <CRLF> isactually the terminator of the previous line (see Section 4.5.2).This is the end of mail data indication. The first <CRLF> of this terminating sequence is also the <CRLF> that ends the final line ofthe data (message text) or, if there was no mail data, ends the DATAcommand itself (the "no mail data" case does not conform to this specification since it would require that neither the trace header fields required by this specification nor the message header section required by RFC 5322 [4] be transmitted).

……

也就是说data命令在"no mail data"场景下,并不需要遵循<CRLF>.<CRLF>的结束格式。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值