This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Call connect() before sending an email with smtplib
Type: behavior Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eric.araujo, python-dev, r.david.murray, sandro.tosi
Priority: normal Keywords: patch

Created on 2011-04-19 20:59 by sandro.tosi, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
smtp_connect-2.7.patch sandro.tosi, 2011-04-19 20:59
smtp_connect-3.2.patch sandro.tosi, 2011-04-19 21:00 review
Messages (5)
msg134100 - (view) Author: Sandro Tosi (sandro.tosi) * (Python committer) Date: 2011-04-19 20:59
Hi, following up http://mail.python.org/pipermail/docs/2011-April/003742.html here are a couple of patches to call connect() after smtplib.SMTP() and sendmail(). Patches are:

2.7: to be applied in 2.7 and merged into 3.1
3.2: to be applied in 3.2 and merged into default

That's because in 3.2 we have a change in the example to use send_message() instead of sendmail() (in order to allow binary contents), and so there's also a small fix to actually make use of send_message() email-simple.
msg134631 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-28 00:12
I’d remove the “Connect to the SMTP server” comment before “s.connect()”.  It’s redundant, contrary to the other comment (which no doubt prompted you to add a comment too) “Send the message via local SMTP server” which helpfully introduces the next lines of code.
msg134885 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-04-30 21:21
New changeset 5c61c1d583fd by R David Murray in branch '3.2':
#11883: replace incorrect call to sendmail with correct call to send_message
http://hg.python.org/cpython/rev/5c61c1d583fd

New changeset fcfaeab42f6e by R David Murray in branch 'default':
Merge #11883: replace incorrect call to sendmail with correct call to send_message
http://hg.python.org/cpython/rev/fcfaeab42f6e
msg134886 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-04-30 21:29
New changeset a9cb47d0241e by R David Murray in branch '2.7':
#11883: fix email examples by adding 'localhost' to SMTP constructor calls
http://hg.python.org/cpython/rev/a9cb47d0241e

New changeset 00ff8825f551 by R David Murray in branch '3.1':
#11883: fix email examples by adding 'localhost' to SMTP constructor calls
http://hg.python.org/cpython/rev/00ff8825f551

New changeset 0f14dd4e644e by R David Murray in branch '3.2':
Merge #11883: fix email examples by adding 'localhost' to SMTP constructor calls
http://hg.python.org/cpython/rev/0f14dd4e644e

New changeset cfc02e132c12 by R David Murray in branch 'default':
Merge #11883: fix email examples by adding 'localhost' to SMTP constructor calls
http://hg.python.org/cpython/rev/cfc02e132c12
msg134887 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-04-30 21:31
The call to connect() is not required in the first example, since the hostname is passed to the constructor in that case.  Since these examples are about the email package rather than smtplib, I preferred to change the other examples to pass localhost to the constructor as well, rather than call connect with no arguments after a no argument call to the constructor.
History
Date User Action Args
2022-04-11 14:57:16adminsetgithub: 56092
2012-01-02 22:54:07sandro.tosilinkissue8245 superseder
2011-04-30 21:31:28r.david.murraysetstatus: open -> closed
type: behavior
messages: + msg134887

resolution: fixed
stage: patch review -> resolved
2011-04-30 21:29:39python-devsetmessages: + msg134886
2011-04-30 21:21:03python-devsetnosy: + python-dev
messages: + msg134885
2011-04-28 00:12:47eric.araujosetnosy: + eric.araujo
messages: + msg134631
2011-04-19 21:00:43sandro.tosisetfiles: + smtp_connect-3.2.patch
2011-04-19 20:59:21sandro.tosicreate