I am using EmailMessage class to send mail, but I am getting the following issue:
People marked in Cc receiving mails as bcc
The minimal code to reproduce the result is as follows:
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
})
Also, how to handle if I don't get some fields like cc, bcc in some request?
Any help is highly appreciated.
I had to pass Cc in headers as follows:
headers = {'Cc': ','.join(cc_list)}