Send mass mail with hidden recipients

巧了我就是萌 提交于 2019-12-23 06:04:50

问题


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.


回答1:


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=['user@email.com',])
message.send()



回答2:


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.



来源:https://stackoverflow.com/questions/29088069/send-mass-mail-with-hidden-recipients

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!