python3.7 smtplib_smtplib ---SMTP协议客户端 — Python 3.7.9 說明文件

Send mail. The required arguments are an RFC 822 from-address string, a list

of RFC 822 to-address strings (a bare string will be treated as a list with 1

address), and a message string. The caller may pass a list of ESMTP options

(such as 8bitmime) to be used in MAIL FROM commands as mail_options.

ESMTP options (such as DSN commands) that should be used with all RCPT

commands can be passed as rcpt_options. (If you need to use different ESMTP

options to different recipients you have to use the low-level methods such as

mail(), rcpt() and data() to send the message.)

備註

The from_addr and to_addrs parameters are used to construct the message

envelope used by the transport agents. sendmail does not modify the

message headers in any way.

msg may be a string containing characters in the ASCII range, or a byte

string. A string is encoded to bytes using the ascii codec, and lone \r

and \n characters are converted to \r\n characters. A byte string is

not modified.

If there has been no previous EHLO or HELO command this session, this

method tries ESMTP EHLO first. If the server does ESMTP, message size and

each of the specified options will be passed to it (if the option is in the

feature set the server advertises). If EHLO fails, HELO will be tried

and ESMTP options suppressed.

This method will return normally if the mail is accepted for at least one

recipient. Otherwise it will raise an exception. That is, if this method does

not raise an exception, then someone should get your mail. If this method does

not raise an exception, it returns a dictionary, with one entry for each

recipient that was refused. Each entry contains a tuple of the SMTP error code

and the accompanying error message sent by the server.

If SMTPUTF8 is included in mail_options, and the server supports it,

from_addr and to_addrs may contain non-ASCII characters.

This method may raise the following exceptions:

All recipients were refused. Nobody got the mail. The recipients

attribute of the exception object is a dictionary with information about the

refused recipients (like the one returned when at least one recipient was

accepted).

The server didn't reply properly to the HELO greeting.

The server didn't accept the from_addr.

The server replied with an unexpected error code (other than a refusal of a

recipient).

SMTPUTF8 was given in the mail_options but is not supported by the

server.

Unless otherwise noted, the connection will be open even after an exception is

raised.

3.2 版更變:msg may be a byte string.

3.5 版更變:SMTPUTF8 support added, and SMTPNotSupportedError may be

raised if SMTPUTF8 is specified but the server does not support it.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值