django 发送电子邮件(送达报告)
django sending email (delivery report)
我是初学者,正在尝试使用 "Django" 向多个收件人发送邮件。
我怎么能得到一份送达报告,告诉我:"the mail delivered to recipients a,b,c and d"。
"The delivery failed to recipient (e) because his mail box is full"。
由于您的邮件被视为垃圾邮件,无法发送至收件人 (f)。
send_mail() 的 return 值是一个布尔值,表示消息是否已成功发送。
您可以编写一个函数来遍历收件人列表,调用 send_mail(),将成功投递的邮件附加到一个列表,并将不成功的收件人附加到另一个列表。然后您可以使用该信息编写消息。像这样:
recipients = [ ... ] # list of people you're sending the email to
successful_recipients = []
unsuccessful_recipients = []
for recipient in recipients:
if send_mail( ... ):
successful_recipients.append(recipient)
else:
unsuccessful_recipients.append(recipient)
可能需要 difficult/impossible 才能找到失败的原因,因为 Django 不会为您提供该信息。
我是初学者,正在尝试使用 "Django" 向多个收件人发送邮件。 我怎么能得到一份送达报告,告诉我:"the mail delivered to recipients a,b,c and d"。 "The delivery failed to recipient (e) because his mail box is full"。 由于您的邮件被视为垃圾邮件,无法发送至收件人 (f)。
send_mail() 的 return 值是一个布尔值,表示消息是否已成功发送。
您可以编写一个函数来遍历收件人列表,调用 send_mail(),将成功投递的邮件附加到一个列表,并将不成功的收件人附加到另一个列表。然后您可以使用该信息编写消息。像这样:
recipients = [ ... ] # list of people you're sending the email to
successful_recipients = []
unsuccessful_recipients = []
for recipient in recipients:
if send_mail( ... ):
successful_recipients.append(recipient)
else:
unsuccessful_recipients.append(recipient)
可能需要 difficult/impossible 才能找到失败的原因,因为 Django 不会为您提供该信息。