Skip to content
20 changes: 13 additions & 7 deletions Doc/library/smtplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

.. class:: SMTP(host='', port=0, local_hostname=None[, timeout], source_address=None)

An :class:`SMTP` instance encapsulates an SMTP connection. It has methods

Check warning on line 26 in Doc/library/smtplib.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:attr reference target not found: default_port [ref.attr]
that support a full repertoire of SMTP and ESMTP operations. If the optional
*host* and *port* parameters are given, the SMTP :meth:`connect` method is
called with those parameters during initialization. If specified,
*local_hostname* is used as the FQDN of the local host in the HELO/EHLO
that support a full repertoire of SMTP and ESMTP operations.
If *host* is omitted or set to an empty string, no connection is made during initialization; you must
call :meth:`connect` manually before using the instance.
If *port* is zero,the value of the :attr:`default_port` attribute is used.

If specified, *local_hostname* is used as the FQDN of the local host in the HELO/EHLO
Comment thread
bitdancer marked this conversation as resolved.
command. Otherwise, the local hostname is found using
:func:`socket.getfqdn`. If the :meth:`connect` call returns anything other
Comment thread
bitdancer marked this conversation as resolved.
than a success code, an :exc:`SMTPConnectError` is raised. The optional
Expand Down Expand Up @@ -78,12 +80,16 @@
.. class:: SMTP_SSL(host='', port=0, local_hostname=None, * [, timeout], \
context=None, source_address=None)

An :class:`SMTP_SSL` instance behaves exactly the same as instances of

Check warning on line 83 in Doc/library/smtplib.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: connect [ref.meth]

Check warning on line 83 in Doc/library/smtplib.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: connect [ref.meth]

Check warning on line 83 in Doc/library/smtplib.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: starttls [ref.meth]
:class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
required from the beginning of the connection and using :meth:`starttls` is
not appropriate. If *host* is not specified, the local host is used. If
*port* is zero, the standard SMTP-over-SSL port (465) is used. The optional
arguments *local_hostname*, *timeout* and *source_address* have the same
not appropriate. If the optional *host* and *port* parameters are given, the
SMTP_SSL :meth:`connect` method is called with those parameters during initialization.
If *host* is omitted or an empty string, no connection is made during initialization;
you must call :meth:`connect` manually before using the instance. If
*port* is zero, the standard SMTP-over-SSL port (465) is used.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original of this is quite a bit less accurate. I would revise it in an identical fashion to the above, again deferring the explanation of what happens with port to the connection docs, including the default port number mention.


The optional arguments *local_hostname*, *timeout* and *source_address* have the same
Comment thread
bitdancer marked this conversation as resolved.
meaning as they do in the :class:`SMTP` class. *context*, also optional,
can contain a :class:`~ssl.SSLContext` and allows configuring various
aspects of the secure connection. Please read :ref:`ssl-security` for
Expand Down
Loading