Skip to content

Commit 6ca9183

Browse files
LamentXU123picnixz
andauthored
gh-101100: Fix sphinx warnings in library/smtplib.rst (#139991)
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent f70082b commit 6ca9183

File tree

2 files changed

+46
-17
lines changed

2 files changed

+46
-17
lines changed

Doc/library/smtplib.rst

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
8080

8181
An :class:`SMTP_SSL` instance behaves exactly the same as instances of
8282
:class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
83-
required from the beginning of the connection and using :meth:`starttls` is
84-
not appropriate. If *host* is not specified, the local host is used. If
83+
required from the beginning of the connection and using :meth:`~SMTP.starttls`
84+
is not appropriate. If *host* is not specified, the local host is used. If
8585
*port* is zero, the standard SMTP-over-SSL port (465) is used. The optional
8686
arguments *local_hostname*, *timeout* and *source_address* have the same
8787
meaning as they do in the :class:`SMTP` class. *context*, also optional,
@@ -112,7 +112,7 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
112112

113113
The LMTP protocol, which is very similar to ESMTP, is heavily based on the
114114
standard SMTP client. It's common to use Unix sockets for LMTP, so our
115-
:meth:`connect` method must support that as well as a regular host:port
115+
:meth:`~SMTP.connect` method must support that as well as a regular host:port
116116
server. The optional arguments *local_hostname* and *source_address* have the
117117
same meaning as they do in the :class:`SMTP` class. To specify a Unix
118118
socket, you must use an absolute path for *host*, starting with a '/'.
@@ -147,9 +147,15 @@ A nice selection of exceptions is defined as well:
147147
.. exception:: SMTPResponseException
148148

149149
Base class for all exceptions that include an SMTP error code. These exceptions
150-
are generated in some instances when the SMTP server returns an error code. The
151-
error code is stored in the :attr:`smtp_code` attribute of the error, and the
152-
:attr:`smtp_error` attribute is set to the error message.
150+
are generated in some instances when the SMTP server returns an error code.
151+
152+
.. attribute:: smtp_code
153+
154+
The error code.
155+
156+
.. attribute:: smtp_error
157+
158+
The error message.
153159

154160

155161
.. exception:: SMTPSenderRefused
@@ -161,9 +167,13 @@ A nice selection of exceptions is defined as well:
161167

162168
.. exception:: SMTPRecipientsRefused
163169

164-
All recipient addresses refused. The errors for each recipient are accessible
165-
through the attribute :attr:`recipients`, which is a dictionary of exactly the
166-
same sort as :meth:`SMTP.sendmail` returns.
170+
All recipient addresses refused.
171+
172+
.. attribute:: recipients
173+
174+
A dictionary of exactly the same sort as returned
175+
by :meth:`SMTP.sendmail` containing the errors for
176+
each recipient.
167177

168178

169179
.. exception:: SMTPDataError
@@ -213,7 +223,6 @@ SMTP Objects
213223

214224
An :class:`SMTP` instance has the following methods:
215225

216-
217226
.. method:: SMTP.set_debuglevel(level)
218227

219228
Set the debug output level. A value of 1 or ``True`` for *level* results in
@@ -417,7 +426,7 @@ An :class:`SMTP` instance has the following methods:
417426

418427
.. versionchanged:: 3.4
419428
The method now supports hostname check with
420-
:attr:`SSLContext.check_hostname` and *Server Name Indicator* (see
429+
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indicator* (see
421430
:const:`~ssl.HAS_SNI`).
422431

423432
.. versionchanged:: 3.5
@@ -435,7 +444,7 @@ An :class:`SMTP` instance has the following methods:
435444
ESMTP options (such as ``DSN`` commands) that should be used with all ``RCPT``
436445
commands can be passed as *rcpt_options*. (If you need to use different ESMTP
437446
options to different recipients you have to use the low-level methods such as
438-
:meth:`mail`, :meth:`rcpt` and :meth:`data` to send the message.)
447+
:meth:`!mail`, :meth:`!rcpt` and :meth:`!data` to send the message.)
439448

440449
.. note::
441450

@@ -467,10 +476,7 @@ An :class:`SMTP` instance has the following methods:
467476
This method may raise the following exceptions:
468477

469478
:exc:`SMTPRecipientsRefused`
470-
All recipients were refused. Nobody got the mail. The :attr:`recipients`
471-
attribute of the exception object is a dictionary with information about the
472-
refused recipients (like the one returned when at least one recipient was
473-
accepted).
479+
All recipients were refused. Nobody got the mail.
474480

475481
:exc:`SMTPHeloError`
476482
The server didn't reply properly to the ``HELO`` greeting.
@@ -546,6 +552,30 @@ Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``,
546552
Normally these do not need to be called directly, so they are not documented
547553
here. For details, consult the module code.
548554

555+
Additionally, an SMTP instance has the following attributes:
556+
557+
558+
.. attribute:: SMTP.helo_resp
559+
560+
The response to the ``HELO`` command, see :meth:`helo`.
561+
562+
563+
.. attribute:: SMTP.ehlo_resp
564+
565+
The response to the ``EHLO`` command, see :meth:`ehlo`.
566+
567+
568+
.. attribute:: SMTP.does_esmtp
569+
570+
A boolean value indicating whether the server supports ESMTP, see
571+
:meth:`ehlo`.
572+
573+
574+
.. attribute:: SMTP.esmtp_features
575+
576+
A dictionary of the names of SMTP service extensions supported by the server,
577+
see :meth:`ehlo`.
578+
549579

550580
.. _smtp-example:
551581

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Doc/library/profile.rst
2929
Doc/library/pyexpat.rst
3030
Doc/library/resource.rst
3131
Doc/library/select.rst
32-
Doc/library/smtplib.rst
3332
Doc/library/socket.rst
3433
Doc/library/ssl.rst
3534
Doc/library/stdtypes.rst

0 commit comments

Comments
 (0)