比方说,你在被覆盖的类处理消息,如:如何拒绝smtpd.SMTPServer.process_message中的收件人?
class MailProcessorServer(smtpd.SMTPServer):
def process_message(self, peer, sender, rcpttos, data):
badrecipients = []
for rcpt in rcpttos:
badrecipients.append(rcpt)
#Here I want to warn the sender via a bounced email
# that the recipient does not exist
raise smtplib.SMTPRecipientsRefused(badrecipients)
#but this just crashes the process and eventually the sender times out,
# not good enough
我只想马上退回给发件人。相反,发送服务(比如GMail)最终放弃并在几个小时后警告用户。 documentation似乎很稀疏。
+1的链接来源 – nalply 2011-05-17 07:45:13