你确定要断开连接吗?当我在postfix服务器上运行上述代码时,我得到:
connect: ( server , 25 )
connect: ( ip.address , 25)
reply: 220 server ESMTP Postfix
reply: retcode (220); Msg: nserver ESMTP Postfix
connect: server ESMTP Postfix
send: NOOP
reply: 250 2.0.0 Ok
reply: retcode (250); Msg: 2.0.0 Ok
0.0531799793243
docmd不阻止,服务器响应,程序退出。因此,当程序退出时,我会断开连接。
如果我打开一个python命令行并执行以下操作:
>> import smtplib
>> server = smtplib.SMTP()
>> server.connect( server )
>> server.docmd( NOOP )
(250, 2.0.0 Ok )
>> ## let it sit for 5 minutes
>> server.docmd( NOOP )
(421, 4.4.2 server Error: timeout exceeded )
我的日志证实了这一点:
Oct 20 10:45:35 [postfix/smtpd] connect from unknown[ip.address]
Oct 20 10:50:10 [postfix/smtpd] timeout after NOOP from unknown[ip.address]