Send mail with python using bcc

一曲冷凌霜 提交于 2020-01-01 07:23:51

问题


I'm working with django, i need send a mail to many emails, i want to do this with a high level library like python-mailer, but i need use bcc field, any suggestions?


回答1:


You should look at the EmailMessage class inside of django, supports the bcc.

Complete docs availble here: http://docs.djangoproject.com/en/dev/topics/email/#the-emailmessage-class

Quick overview:

The EmailMessage class is initialized with the following parameters (in the given order, if positional arguments are used). All parameters are optional and can be set at any time prior to calling the send() method.

  • subject: The subject line of the e-mail.
  • body: The body text. This should be a plain text message.
  • from_email: The sender's address. Both fred@example.com and Fred forms are legal. If omitted, the DEFAULT_FROM_EMAIL setting is used.
  • to: A list or tuple of recipient addresses.
  • bcc: A list or tuple of addresses used in the "Bcc" header when sending the e-mail.
  • connection: An e-mail backend instance. Use this parameter if you want to use the same connection for multiple messages. If omitted, a new connection is created when send() is called.
  • attachments: A list of attachments to put on the message. These can be either email.MIMEBase.MIMEBase instances, or (filename, content, mimetype) triples.
  • headers: A dictionary of extra headers to put on the message. The keys are the header name, values are the header values. It's up to the caller to ensure header names and values are in the correct format for an e-mail message.


来源:https://stackoverflow.com/questions/3470172/send-mail-with-python-using-bcc

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