简体   繁体   English

使用密件抄送使用python发送邮件

[英]Send mail with python using bcc

我正在使用django,我需要向许多电子邮件发送邮件,我想使用像python-mailer这样的高级库来执行此操作,但是我需要使用密件抄送字段,有什么建议吗?

You should look at the EmailMessage class inside of django, supports the bcc. 您应该查看django中的EmailMessage类,它支持密件抄送。

Complete docs availble here: http://docs.djangoproject.com/en/dev/topics/email/#the-emailmessage-class 完整的文档在这里可用: 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). EmailMessage类使用以下参数初始化(如果使用位置参数,则以给定的顺序)。 All parameters are optional and can be set at any time prior to calling the send() method. 所有参数都是可选的,可以在调用send()方法之前的任何时间进行设置。

  • 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. from_email:发件人的地址。 Both fred@example.com and Fred forms are legal. fred@example.com和Fred表格都是合法的。 If omitted, the DEFAULT_FROM_EMAIL setting is used. 如果省略,则使用DEFAULT_FROM_EMAIL设置。
  • 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. bcc :发送电子邮件时,在“密件抄送”标头中使用的地址列表或元组。
  • 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. 如果省略,则在调用send()时创建一个新连接。
  • attachments: A list of attachments to put on the message. 附件:要放入邮件的附件列表。 These can be either email.MIMEBase.MIMEBase instances, or (filename, content, mimetype) triples. 这些可以是email.MIMEBase.MIMEBase实例,也可以是(文件名,内容,mimetype)三元组。
  • 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. 调用者应确保标题名称和值的格式正确无误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM