Reputation: 141
Does Django's Mailgun API support bcc? I can't find much and whenever I try to use bcc as shown below it sends the bcc address as a to email (making it visible to all). Thanks!
the_email = EmailMessage(subject=subject, body=body, from_email=from_email, to=to_email, bcc=("[email protected]",))
Upvotes: 0
Views: 278
Reputation: 141
As said by solarissmoke above, django-mailgun doesn't support BCC. At least by default. If you go into the source code it is easy enough to add bcc support. Within the django_mailgun.py file change from:
recipients = [sanitize_address(addr, email_message.encoding)
for addr in email_message.recipients()]
try:
post_data = []
post_data.append(('to', (",".join(recipients)),))
to:
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)),))
and voila, bcc support. You can also make changes similar to above to add cc support. It turned out they were just straight reading recipients which caused bcc to be dropped and just added them directly in the to list. Hope this helped out anyone else who may have encountered a similar issue.
Upvotes: 1