@@ -25,9 +25,9 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
2525
2626 An :class: `SMTP ` instance encapsulates an SMTP connection. It has methods
2727 that support a full repertoire of SMTP and ESMTP operations.
28- If * host * is omitted or set to an empty string, no connection is made during initialization; you must
29- call :meth: `connect ` manually before using the instance.
30- If * port * is zero,the value of the :attr: ` default_port ` attribute is used .
28+ If the host parameter is set to a truthy value, :meth: ` connect(host, port) ` is
29+ called automatically when the object is created, otherwise :meth: `connect ` must be
30+ called manually .
3131
3232 If specified, *local_hostname * is used as the FQDN of the local host in the HELO/EHLO
3333 command. Otherwise, the local hostname is found using
@@ -64,6 +64,10 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
6464 ``smtplib.SMTP.send `` with arguments ``self `` and ``data ``,
6565 where ``data `` is the bytes about to be sent to the remote host.
6666
67+ .. attribute :: SMTP.default_port
68+
69+ The default port used for SMTP connections (25).
70+
6771 .. versionchanged :: 3.3
6872 Support for the :keyword: `with ` statement was added.
6973
@@ -83,18 +87,20 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
8387 An :class: `SMTP_SSL ` instance behaves exactly the same as instances of
8488 :class: `SMTP `. :class: `SMTP_SSL ` should be used for situations where SSL is
8589 required from the beginning of the connection and using :meth: `starttls ` is
86- not appropriate. If the optional *host * and *port * parameters are given, the
87- SMTP_SSL :meth: `connect ` method is called with those parameters during initialization.
88- If *host * is omitted or an empty string, no connection is made during initialization;
89- you must call :meth: `connect ` manually before using the instance. If
90- *port * is zero, the standard SMTP-over-SSL port (465) is used.
90+ not appropriate. If the host parameter is set to a truthy value,
91+ :meth: `connect(host, port) ` is called automatically when the object is created,
92+ otherwise :meth: `connect ` must be called manually.
9193
9294 The optional arguments *local_hostname *, *timeout * and *source_address * have the same
9395 meaning as they do in the :class: `SMTP ` class. *context *, also optional,
9496 can contain a :class: `~ssl.SSLContext ` and allows configuring various
9597 aspects of the secure connection. Please read :ref: `ssl-security ` for
9698 best practices.
9799
100+ .. attribute :: SMTP_SSL.default_port
101+
102+ The default port used for SMTP-over-SSL connections (465).
103+
98104 .. versionchanged :: 3.3
99105 *context * was added.
100106
@@ -256,6 +262,8 @@ An :class:`SMTP` instance has the following methods:
256262 2-tuple of the response code and message sent by the server in its
257263 connection response.
258264
265+ If the port is not specified, the value of the :attr: `default_port ` attribute is used.
266+
259267 .. audit-event :: smtplib.connect self,host,port smtplib.SMTP.connect
260268
261269
0 commit comments