22\section {Standard Module \module {smtplib} }
33\stmodindex {smtplib}
44\label {module-smtplib }
5+ \indexii {SMTP}{protocol}
6+ \index {Simple Mail Transfer Protocol}
57
6- The \module {smtplib} module defines an SMTP session object that can be
7- used to send mail to any Internet machine with an SMTP or ESMTP
8+ The \module {smtplib} module defines an SMTP client session object that
9+ can be used to send mail to any Internet machine with an SMTP or ESMTP
810listener daemon. For details of SMTP and ESMTP operation, consult
911\rfc {821} (\emph {Simple Mail Transfer Protocol }) and \rfc {1869}
1012(\emph {SMTP Service Extensions }).
1113
12- \begin {classdesc }{SMTP}{\optional {host, port}}
14+ \begin {classdesc }{SMTP}{\optional {host\optional { , port} }}
1315A \class {SMTP} instance encapsulates an SMTP connection. It has
1416methods that support a full repertoire of SMTP and ESMTP
1517operations. If the optional host and port parameters are given, the
@@ -21,6 +23,7 @@ \section{Standard Module \module{smtplib}}
2123included below.
2224\end {classdesc }
2325
26+
2427\subsection {SMTP Objects }
2528\label {SMTP-objects }
2629
@@ -32,8 +35,9 @@ \subsection{SMTP Objects}
3235received from the server.
3336\end {methoddesc }
3437
35- \begin {methoddesc }{connect}{\optional {host='localhost'\optional {, port=0}}}
36- Connect to a host on a given port.
38+ \begin {methoddesc }{connect}{\optional {host\optional {, port}}}
39+ Connect to a host on a given port. The defaults are to connect to the
40+ local host at the standard SMTP port (25).
3741
3842If the hostname ends with a colon (\character {:}) followed by a
3943number, that suffix will be stripped off and the number interpreted as
@@ -58,18 +62,19 @@ \subsection{SMTP Objects}
5862\end {methoddesc }
5963
6064\begin {methoddesc }{helo}{\optional {hostname}}
61- Identify yourself to the SMTP server using HELO. The hostname
62- argument defaults to the FQDN of the local host.
65+ Identify yourself to the SMTP server using \samp {HELO}. The hostname
66+ argument defaults to the fully qualified domain name of the local
67+ host.
6368
6469In normal operation it should not be necessary to call this method
6570explicitly. It will be implicitly called by the \method {sendmail()}
6671when necessary.
6772\end {methoddesc }
6873
6974\begin {methoddesc }{ehlo}{\optional {hostname}}
70- Identify yourself to an ESMTP server using HELO. The hostname
71- argument defaults to the FQDN of the local host. Examine the
72- response for ESMTP option and store them for use by
75+ Identify yourself to an ESMTP server using \samp { HELO} . The hostname
76+ argument defaults to the fully qualified domain name of the local
77+ host. Examine the response for ESMTP option and store them for use by
7378\method {has_option()}.
7479
7580Unless you wish to use \method {has_option()} before sending
@@ -83,43 +88,45 @@ \subsection{SMTP Objects}
8388\end {methoddesc }
8489
8590\begin {methoddesc }{verify}{address}
86- Check the validity of an address on this server using SMTP VRFY.
91+ Check the validity of an address on this server using SMTP \samp { VRFY} .
8792Returns a tuple consisting of code 250 and a full \rfc {822} address
8893(including human name) if the user address is valid. Otherwise returns
8994an SMTP error code of 400 or greater and an error string.
9095
91- Note: many sites disable SMTP VRFY in order to foil spammers.
96+ Note: many sites disable SMTP \samp { VRFY} in order to foil spammers.
9297\end {methoddesc }
9398
94- \begin {methoddesc }{sendmail}{from_addr, to_addrs, msg\optional {, options=[]}}
95- Send mail. The required arguments are an \rfc {822} from-address string,
96- a list of \rfc {822} to-address strings, and a message string. The caller
97- may pass a list of ESMTP options to be used in MAIL FROM commands.
99+ \begin {methoddesc }{sendmail}{from_addr, to_addrs, msg\optional {, options}}
100+ Send mail. The required arguments are an \rfc {822} from-address
101+ string, a list of \rfc {822} to-address strings, and a message string.
102+ The caller may pass a list of ESMTP options to be used in \samp {MAIL
103+ FROM} commands as \var {options}.
98104
99- If there has been no previous EHLO or HELO command this session, this
100- method tries ESMTP EHLO first. If the server does ESMTP, message size
101- and each of the specified options will be passed to it (if the option
102- is in the feature set the server advertises). If EHLO fails, HELO
103- will be tried and ESMTP options suppressed.
105+ If there has been no previous \samp {EHLO} or \samp {HELO} command this
106+ session, this method tries ESMTP \samp {EHLO} first. If the server does
107+ ESMTP, message size and each of the specified options will be passed
108+ to it (if the option is in the feature set the server advertises). If
109+ \samp {EHLO} fails, \samp {HELO} will be tried and ESMTP options
110+ suppressed.
104111
105112This method will return normally if the mail is accepted for at least
106113one recipient. Otherwise it will throw an exception (either
107114\exception {SMTPSenderRefused}, \exception {SMTPRecipientsRefused}, or
108- \exception {SMTPDataError}).
109- That is, if this method does not throw an exception, then someone
110- should get your mail. If this method does not throw an exception,
111- it returns a dictionary, with one entry for each recipient that was
112- refused.
115+ \exception {SMTPDataError}). That is, if this method does not throw an
116+ exception, then someone should get your mail. If this method does not
117+ throw an exception, it returns a dictionary, with one entry for each
118+ recipient that was refused.
113119\end {methoddesc }
114120
115121\begin {methoddesc }{quit}{}
116122Terminate the SMTP session and close the connection.
117123\end {methoddesc }
118124
119125Low-level methods corresponding to the standard SMTP/ESMTP commands
120- HELP, RSET, NOOP, MAIL, RCPT, and DATA are also supported. Normally
121- these do not need to be called directly, so they are not documented
122- here. For details, consult the module code.
126+ \samp {HELP}, \samp {RSET}, \samp {NOOP}, \samp {MAIL}, \samp {RCPT}, and
127+ \samp {DATA} are also supported. Normally these do not need to be
128+ called directly, so they are not documented here. For details,
129+ consult the module code.
123130
124131
125132\subsection {SMTP Example }
0 commit comments