Django的Mailgun API是否支持密件抄送?我找不到太多,每当我尝试使用如下所示的密件抄送时,它会将密件抄送地址作为电子邮件发送给所有人。谢谢!
the_email = EmailMessage(subject=subject, body=body, from_email=from_email, to=to_email, bcc=("myemail@gmail.com",))
答案 0 :(得分:1)
正如上面提到的solarissmoke所说,django-mailgun不支持BCC。至少默认情况下。如果你进入源代码,很容易添加bcc支持。在django_mailgun.py文件中更改为:
recipients = [sanitize_address(addr, email_message.encoding)
for addr in email_message.recipients()]
try:
post_data = []
post_data.append(('to', (",".join(recipients)),))
为:
to_recip = [sanitize_address(addr, email_message.encoding)
for addr in email_message.to]
bcc_recip = [sanitize_address(addr, email_message.encoding)
for addr in email_message.bcc]
try:
post_data = []
post_data.append(('to', (",".join(to_recip)),))
post_data.append(('bcc', (",".join(bcc_recip)),))
瞧,瞧,bcc的支持。您还可以进行类似上述的更改以添加cc支持。事实证明,他们只是直接读取收件人,导致bcc被删除,只是将它们直接添加到列表中。希望这有助于其他可能遇到类似问题的人。