2013-06-12 83 views
6

views.py發送電子郵件到BCC和CC中的django

if 'send_email' in request.POST: 
    subject, from_email, to = 'Parent Incident Notification',user.email, person.parent_email 
    html_content = render_to_string('incident/print.html',{'person':person, 
                   'report':report, 
                    }) 
    text_content = strip_tags(html_content) 
    msg = EmailMultiAlternatives(subject, text_content, settings.DEFAULT_FROM_EMAIL, [to]) 
    msg.attach_alternative(html_content, "text/html") 
    msg.send() 

以上是發送email.By這樣我可以與郵件一起發送HTML內容的視圖,它是發送電子郵件至[我]想再做一個密送和cc。我通過Emailmessage objects在docs.I不知道如何包括密件抄送和抄送改變我的意見。

需要幫助。

感謝

回答

17

EmailMultiAlternativesEmailMessage一個子類。初始化消息時,您可以指定bcccc

msg = EmailMultiAlternatives(subject, text_content, from_email, [to_email], bcc=[bcc_email], cc=[cc_email])