文档指定您可以包含 mail_options=[]、rcpt_options=[] 作为 sendmail 或 send_message< 的参数。我无法在任何地方找到这些选项的确切内容。我假设在那里的某个地方我可以设置 DSN 等。我已经构建了一个运行良好的电子邮件脚本;不需要有关如何使用 Python 进行 smtp 的帮助。
有人知道描述这些选项以及如何使用它们的文档吗?
https://docs.python.org/3.5/library/smtplib.html
https://docs.python.org/3.5/library/email-examples.html#email-examples
请您参考如下方法:
如果 SMTP 服务器正确响应“EHLO”命令,则它支持 ESMTP。
8BITMIME —8 bit data transmission, RFC 6152[1]
ATRN —Authenticated TURN for On-Demand Mail Relay, RFC 2645[2]
AUTH —Authenticated SMTP, RFC 4954[3]
CHUNKING —Chunking, RFC 3030[4]
DSN —Delivery status notification, RFC 3461[5]
ETRN —Extended version of remote message queue starting command TURN, RFC
1985[6]
HELP —Supply helpful information, RFC 821[7]
PIPELINING —Command pipelining, RFC 2920[8]
SIZE —Message size declaration, RFC 1870[9]
STARTTLS —Transport layer security, RFC 3207 (2002)[10]
- Not relevant in python3 as it is a separate function
SMTPUTF8 —Allow UTF-8 encoding in mailbox names and header fields, RFC 6531[11]
DSN 用法/语法示例:
smtp.send_message(msg, rcpt_options=['NOTIFY=SUCCESS,DELAY,FAILURE'])
注意事项:
- ESMTP 规范指出,DSN 可以用字符大小写的任意组合和选项(成功、延迟或失败)的任意组合来指定。
- DSN 功能取决于从发件人到收件人的每个电子邮件服务器都支持它。
引用资料:
- [1] https://www.rfc-editor.org/rfc/rfc6152
- [2] https://www.rfc-editor.org/rfc/rfc2645
- [3] https://www.rfc-editor.org/rfc/rfc4954
- [4] https://www.rfc-editor.org/rfc/rfc3030
- [5] https://www.rfc-editor.org/rfc/rfc3461
- [6] https://www.rfc-editor.org/rfc/rfc1985
- [7] https://www.rfc-editor.org/rfc/rfc821
- [8] https://www.rfc-editor.org/rfc/rfc2920
- [9] https://www.rfc-editor.org/rfc/rfc1870
- [10] https://www.rfc-editor.org/rfc/rfc3207
- [11] https://www.rfc-editor.org/rfc/rfc6531
- https://docs.python.org/3.5/library/smtplib.html
- https://en.wikipedia.org/wiki/Extended_SMTP
