小编Car*_*ver的帖子

如何在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
Run Code Online (Sandbox Code Playgroud)

我只想立即回复发件人.相反,发送服务(比如GMail)最终会放弃,并在几小时后警告用户.该文件似乎很稀疏.

python email smtp

1
推荐指数
1
解决办法
1901
查看次数

标签 统计

email ×1

python ×1

smtp ×1