是否可以向 SMTP 服务器发送某种 ping 命令来检查连接是否仍然打开并准备好发送邮件
该连接保持活动状态,需要检查连接是否已关闭/超时
或者是否可以发送不操作命令来保持连接处于活动状态?
答案1
快速浏览一下 RFC 节目SMTP NOOP 命令。
This command does not affect any parameters or previously entered commands. It specifies no action other than that the receiver send a "250 OK" reply. This command has no effect on the reverse-path buffer, the forward- path buffer, or the mail data buffer, and it may be issued at any time. If a parameter string is specified, servers SHOULD ignore it.
答案2
NOOP
很好,但RSET
更好在开始新交易之前(发送新邮件)恕我直言。
无论如何,sendmail
它都用于RSET
测试从连接缓存中检索到的 SMTP 连接。