views.py
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()
The above is the view to send email.By that way i can send the html content along with mail,it is sending the email to [to] address alone ,i want to made another bcc and cc also.I gone through the Emailmessage objects in docs.I don't know how to include the bcc and cc to alter my views.
Need help.
Thanks
EmailMultiAlternatives is a subclass of EmailMessage. You can specify bcc and cc when you initialise the message.
msg = EmailMultiAlternatives(subject, text_content, from_email, [to_email], bcc=[bcc_email], cc=[cc_email])
EmailMessage now supports cc and bcc:
https://docs.djangoproject.com/en/1.10/topics/email/#django.core.mail.EmailMessage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With