-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-137339: Clarify host and port parameter behavior in smtplib.SMTP_SSL initialization #137340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bitdancer
merged 10 commits into
python:main
from
Aniketsy:docs/smtplib-clarify-host-port
Nov 11, 2025
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
65451a6
Clarify host and port parameter behavior in smtplib.SMTP_SSL initiali…
Aniketsy 7337b6d
Clarify host and port parameter behavior in smtplib.SMTP_SSL initiali…
Aniketsy 54907a0
Clarify smtplib docs: host/port explanation
Aniketsy 4be90cd
Update SMTP and SMTP_SSL docs for host/port
Aniketsy d975adf
Update SMTP and SMTP_SSL docs for host/port
Aniketsy 220e8f6
Merge branch 'main' into docs/smtplib-clarify-host-port
Aniketsy 749a316
Update Doc/library/smtplib.rst
Aniketsy e4d78cf
Update SMTP and SMTP_SSL docs for host/port
Aniketsy f779ba4
Update SMTP and SMTP_SSL docs for host/port
Aniketsy ae806be
Update Doc/library/smtplib.rst
Aniketsy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,10 +24,12 @@ | |
| .. class:: SMTP(host='', port=0, local_hostname=None[, timeout], source_address=None) | ||
|
|
||
| An :class:`SMTP` instance encapsulates an SMTP connection. It has methods | ||
| 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 the host parameter is set to a truthy value, :meth:`SMTP.connect` is | ||
| called automatically when the object is created, otherwise :meth:`connect` must be | ||
| called manually. | ||
|
|
||
| If specified, *local_hostname* is used as the FQDN of the local host in the HELO/EHLO | ||
| command. Otherwise, the local hostname is found using | ||
| :func:`socket.getfqdn`. If the :meth:`connect` call returns anything other | ||
bitdancer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| than a success code, an :exc:`SMTPConnectError` is raised. The optional | ||
|
|
@@ -62,6 +64,10 @@ | |
| ``smtplib.SMTP.send`` with arguments ``self`` and ``data``, | ||
| where ``data`` is the bytes about to be sent to the remote host. | ||
|
|
||
| .. attribute:: SMTP.default_port | ||
|
|
||
| The default port used for SMTP connections (25). | ||
|
|
||
| .. versionchanged:: 3.3 | ||
| Support for the :keyword:`with` statement was added. | ||
|
|
||
|
|
@@ -78,17 +84,23 @@ | |
| .. 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 | ||
| :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is | ||
| required from the beginning of the connection and using :meth:`~SMTP.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 | ||
| required from the beginning of the connection and using :meth:`SMTP.starttls` is | ||
| not appropriate. If the host parameter is set to a truthy value, | ||
| :meth:`SMTP.connect` is called automatically when the object is created, | ||
|
||
| otherwise :meth:`connect` must be called manually. | ||
Aniketsy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The optional arguments *local_hostname*, *timeout* and *source_address* have the same | ||
bitdancer marked this conversation as resolved.
Show resolved
Hide 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 | ||
| best practices. | ||
|
|
||
| .. attribute:: SMTP_SSL.default_port | ||
|
|
||
| The default port used for SMTP-over-SSL connections (465). | ||
|
|
||
| .. versionchanged:: 3.3 | ||
| *context* was added. | ||
|
|
||
|
|
@@ -259,6 +271,8 @@ | |
| 2-tuple of the response code and message sent by the server in its | ||
| connection response. | ||
|
|
||
| If the port is not specified, the value of the :attr:`default_port` attribute is used. | ||
|
||
|
|
||
| .. audit-event:: smtplib.connect self,host,port smtplib.SMTP.connect | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.