43👍
✅
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])
9👍
EmailMessage
now supports cc
and bcc
:
https://docs.djangoproject.com/en/1.10/topics/email/#django.core.mail.EmailMessage
- Create a canonical "parent" product in Django Oscar programmatically
- Django REST Framework Swagger 2.0
- Django 1.6 and django-registration: built-in authentication views not picked up
2👍
I needed bcc with HTML content as body and here is my implementation
from django.core.mail import EmailMessage
email = EmailMessage(
'Subject',
'htmlBody',
'from@email.com',
[to@email.com],
[bcc@email.com],
reply_to=['reply_to@email.com']
)
email.content_subtype = "html"
email.send(fail_silently=True)
For more details refer Django docs
- Make Django test case database visible to Celery
- Python Social Auth Django template example
- Making Twitter, Tastypie, Django, XAuth and iOS work to Build Django-based Access Permissions
- How can my Model primary key start with a specific number?
0👍
You can use TextField
class Client(models.Model):
bcc = models.TextField(null=True, blank=True)
Input multiple emails like this (bcc field): test1@example.com,test2@example.com
from django.core.mail import EmailMessage
clients= Client.objects.all()
for client in clients:
subject = client.subject
content = client.body
contact_email = client.msg_from
to = client.msg_to
bcc_mails = client.bcc
bcc = bcc_mails.split(",")
bcc_mails.replace('"', "")
email = EmailMessage(
subject,
content,
contact_email,
[to],
bcc,
headers={'Reply-To': contact_email}
)
Source:stackexchange.com