【问题标题】:EmailMessage django cc behaving as bccEmailMessage django cc 表现为密件抄送
【发布时间】:2020-01-18 18:18:54
【问题描述】:

我正在使用 EmailMessage 类发送邮件,但遇到以下问题:

People marked in Cc receiving mails as bcc

重现结果的最少代码如下:

def send_mails(subject, html_message, sender_mail, recipient_list, bcc_list, cc_list, reply_to):
    headers = {'Cc': cc_list}
    email = EmailMessage(subject, html_message, sender_mail,
                         recipient_list, bcc_list, reply_to=reply_to, headers=headers)

    email.content_subtype = 'html'
    email.send()
send_mails(request.data['subject'], html_message, request.data['sender_mail'],
                       request.data['recipient_list'], request.data['bcc_list'],cc_list, request.data['reply_to'])
from django.template import loader

html_message = loader.render_to_string(
    'send/base.html',
    {
        'product_name': request.data['product_name'],
        'sender': request.data['sender_mail'],
        'body':  request.data['body'],
        'bgcolor': bgcolor,
        'product_url': request.data['product_url'],
        'bg_img': bg_img

    })

另外,如果我在某些请求中没有得到像cc,bcc这样的字段,如何处理?

非常感谢任何帮助。

【问题讨论】:

    标签: django html-email email-attachments django-email


    【解决方案1】:

    我必须按如下方式在标头中传递抄送:

    headers = {'Cc': ','.join(cc_list)}
    

    【讨论】:

      猜你喜欢
      • 2013-06-08
      • 2011-12-26
      • 2015-12-19
      • 2015-03-27
      • 2015-01-02
      • 2011-04-02
      • 2014-05-23
      • 2015-10-01
      • 2014-10-28
      相关资源
      最近更新 更多