假设您在重写的类中处理消息,例如:
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
Run Code Online (Sandbox Code Playgroud)
我只想立即回复发件人.相反,发送服务(比如GMail)最终会放弃,并在几小时后警告用户.该文件似乎很稀疏.