steven2308
steven2308

Reputation: 2531

Send mass mail with hidden recipients

I have a functionality in a Django app to send an email to all the registered users, I'm currently doing it with 'EmailMessage' and it works perfectly but everybody gets to see every other recipient's email which is unwanted.

Is there a way to hide recipients using the Django mailing functions?

Thank you.

Upvotes: 2

Views: 2602

Answers (3)

Amar Kumar
Amar Kumar

Reputation: 2646

You can try this code format if you want to send Mass Email using send_mass_mail() function.

from django.core.mail import send_mass_mail

subject = 'test subject'
message = 'test message'
from_email = '[email protected]'
recipient_list = ['[email protected]', '[email protected]', '[email protected]']

messages = [(subject, message, from_email, [recipient]) for recipient in recipient_list]

send_mass_mail(messages)

Upvotes: 0

rkirmizi
rkirmizi

Reputation: 364

when you instantiate EmailMessage class you can provide bcc attribute such as the example.

Here is the EmailMessage class

class EmailMessage(object):
"""
A container for email information.
"""
content_subtype = 'plain'
mixed_subtype = 'mixed'
encoding = None     # None => use settings default

def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
             connection=None, attachments=None, headers=None, cc=None):

so if you provide bcc recipient with the attribute name. you can set the target email as bcc recipient.

message = EmailMessage('hello', 'body', bcc=['[email protected]',])
message.send()

Upvotes: 3

Burrito
Burrito

Reputation: 515

http://en.wikipedia.org/wiki/Blind_carbon_copy

https://docs.djangoproject.com/en/1.7/topics/email/

Definitely BCC each address, this should hide them for any recipient. By the looks of the docs you will need to create your own EmailMessage rather than using the predefined wrappers.

Upvotes: 3

Related Questions