Commit Graph

68 Commits

Author SHA1 Message Date
R David Murray 0cff49fcf9 #22215: have the smtplib 'quit' command reset the state.
Without this reset, starttls would fail if a connect/starttls was done after a
quit, because smtplib assumed the existing value of emspt_features was
accurate, but it gets reset when starttls completes (and the new value does
not contain the starttls capability, since tls is already started at that
point).  (There may be additional places where this lack of reset was an
issue as well.)

Patch by Milan Oberkirch.
2014-08-30 16:51:59 -04:00
R David Murray afb151a5cc #17498: Defer SMTPServerDisconnected errors until the next command.
Normally an SMTP server will return an error, and smtplib will then issue an
RSET to return the connection to the known starting state.  Some servers,
however, disconnect after issuing certain errors.  When we issue the RSET,
this would result in raising an SMTPServerDisconnected error, *instead* of
returning the error code the user of the library was expecting.  This fix
makes the internal RSET calls ignore the disconnection so that the error code
is returned.  The user of the library will then get the SMTPServerDisconnected
error the next time they try to talk to the server.

Patch by Kushal Das.
2014-04-14 18:21:38 -04:00
Georg Brandl b38b5c43c7 merge with 3.3 2014-02-10 22:11:21 +01:00
Serhiy Storchaka 1ff23d7542 Issue #20549: Use specific asserts in mailbox, smtplib and poplib tests. 2014-02-08 15:06:43 +02:00
Serhiy Storchaka 578c6777aa Issue #20549: Use specific asserts in mailbox, smtplib and poplib tests. 2014-02-08 15:06:08 +02:00
Andrew Kuchling 785918250f Closes #6683: add a test that exercises multiple authentication.
The SMTP server advertises four different authentication methods, and
the code will try CRAM-MD5 first, which will fail, but LOGIN succeeds.
2013-11-11 14:03:23 -05:00
Benjamin Peterson e86eb89b97 merge 3.3 (#19125) 2013-09-29 10:47:04 -04:00
Benjamin Peterson 1eca062be6 fix test to run and test that smtpd does support ELHO (closes #19125) 2013-09-29 10:46:31 -04:00
R David Murray e0a1bf313f Merge: #5713: One more test_smtplib timing fix. 2013-03-21 00:33:30 -04:00
R David Murray 6bd5202227 #5713: One more test_smtplib timing fix. 2013-03-21 00:32:31 -04:00
R David Murray dac94d619c Merge: #5712: Preemptively fix some other possible timing issues. 2013-03-20 22:12:53 -04:00
R David Murray 54bd49d49b Merge: #5712: Preemptively fix some other possible timing issues. 2013-03-20 22:12:14 -04:00
R David Murray 03b0116c78 #5712: Preemptively fix some other possible timing issues. 2013-03-20 22:11:40 -04:00
R David Murray ba7d9d46f2 Merge: #5713: fix timing issue in smtplib tests. 2013-03-20 21:56:03 -04:00
R David Murray a686ed7d10 Merge: #5713: fix timing issue in smtplib tests. 2013-03-20 21:55:14 -04:00
R David Murray 853c0f9d60 #5713: fix timing issue in smtplib tests. 2013-03-20 21:54:05 -04:00
R David Murray 82c6b45c14 Merge: #5713: Handle 421 error codes during sendmail by closing the socket.
This is a partial fix to the issue of servers disconnecting unexpectedly; in
this case the 421 says they are disconnecting, so we close the socket and
return the 421 in the appropriate error context.

Original patch by Mark Sapiro, updated by Kushal Das, with additional
tests by me.
2013-03-20 21:13:56 -04:00
R David Murray f1a40b4ec5 Merge: #5713: Handle 421 error codes during sendmail by closing the socket.
This is a partial fix to the issue of servers disconnecting unexpectedly; in
this case the 421 says they are disconnecting, so we close the socket and
return the 421 in the appropriate error context.

Original patch by Mark Sapiro, updated by Kushal Das, with additional
tests by me.
2013-03-20 21:12:17 -04:00
R David Murray d312c740f1 #5713: Handle 421 error codes during sendmail by closing the socket.
This is a partial fix to the issue of servers disconnecting unexpectedly; in
this case the 421 says they are disconnecting, so we close the socket and
return the 421 in the appropriate error context.

Original patch by Mark Sapiro, updated by Kushal Das, with additional
tests by me.
2013-03-20 20:36:14 -04:00
Andrew Svetlov f7a17b48d7 Replace IOError with OSError (#16715) 2012-12-25 16:47:37 +02:00
Andrew Svetlov 0832af6628 Issue #16717: get rid of socket.error, replace with OSError 2012-12-18 23:10:48 +02:00
Andrew Svetlov 69d03c4799 Cleanup: remove not needed mocks. 2012-12-17 19:27:10 +02:00
Andrew Svetlov 2ade6f24cb Issue #16647: save socket error details in LMTP.connect()
Initial patch by Serhiy Storchaka.
2012-12-17 18:57:16 +02:00
R David Murray d1a30c939c #8739: upgrade smtpd to RFC 5321 and 1870.
smtpd now handles EHLO and has infrastructure for extended smtp command mode.
The SIZE extension is also implemented.  In order to support parameters on
MAIL FROM, the RFC 5322 parser from the email package is used to parse the
address "token".

Logging subclasses things and overrides __init__, so it was necessary to
update those __init__ functions in the logging tests to make the logging tests
pass.

The original suggestion and patch were by Alberto Trevino.  Juhana Jauhiainen
added the --size argument and SIZE parameter support.  Michele Orrù improved
the patch and added more tests.  Dan Boswell conditionalized various bits of
code on whether or not we are in HELO or EHLO mode, as well as some other
improvements and tests.  I finalized the patch and added the address parsing.
2012-05-26 14:33:59 -04:00
Ross Lagerwall 86407432d5 Issue #14442: Add missing errno import in test_smtplib. 2012-03-29 18:08:48 +02:00
Antoine Pitrou 76f570a9c6 Make tests faster by reaping threads only at the end 2011-08-28 01:24:22 +02:00
Antoine Pitrou d54fa555cb Make tests faster by reaping threads only at the end 2011-08-28 01:23:52 +02:00
Senthil Kumaran b351a48eee Addressing the review comments by Antoine Pitrou for smtplib.py and test_smtplib.py. Review comments by Ezio Melotti for smtplib.rst 2011-07-31 09:14:17 +08:00
Senthil Kumaran 3d23fd6493 Fix closes Issue11281 - smtplib.STMP gets source_address parameter, which adds the ability to bind to specific source address on a machine with multiple interfaces. Patch by Paulo Scardine. 2011-07-30 10:56:50 +08:00
R David Murray da7af4d7a1 Merge #7484: no more <> around addresses in VRFY or EXPN 2011-07-18 21:42:28 -04:00
R David Murray 4634676cec #7484: no more <> around addresses in VRFY or EXPN
The RFC doesn't say that they are allowed; apparently many mailers accept
them, but not postfix.  Contributions to this patch were made by Felipe Cruz
and Catalin Iacob.

The changeset also adds additional indirect tests for quoteaddr (null address
and IDNA-encoded address).
2011-07-18 21:38:54 -04:00
R David Murray db4120bf9d merge #12147: make send_message correctly handle Sender and Resent- headers. 2011-07-02 21:10:44 -04:00
R David Murray ac4e5abc78 #12147: make send_message correctly handle Sender and Resent- headers.
Original patch by Nicolas Estibals.  My tweaks to the patch were mostly
style/cosmetic, and adding more tests.
2011-07-02 21:03:19 -04:00
R David Murray 0a9f16b627 merge #12283: Fixed regression in smtplib quoting of leading dots in DATA. 2011-06-09 15:21:02 -04:00
R David Murray 0f663d07e6 #12283: Fixed regression in smtplib quoting of leading dots in DATA.
I unfortunately introduced the regression when I refactored the code,
and there were no tests of quoting so it wasn't caught.  Now there
is one.
2011-06-09 15:05:57 -04:00
R David Murray 477a6eb4a2 Merge: I was right, hardconding the localhost IP doesn't work in linux-vserver. 2011-05-02 08:48:00 -04:00
R David Murray b912c5a004 I was right, hardconding the localhost IP doesn't work in linux-vserver. 2011-05-02 08:47:24 -04:00
Barry Warsaw 1f5c958721 - Issue #11289: `smtp.SMTP` class becomes a context manager so it can be used
in a `with` statement.  Contributed by Giampaolo Rodola.
2011-03-15 15:04:44 -04:00
Ezio Melotti ed3a7d2d60 #10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex. 2010-12-01 02:32:32 +00:00
R. David Murray 7dff9e08fb #10321: Add support for sending binary DATA and Message objects to smtplib 2010-11-08 17:15:13 +00:00
Benjamin Peterson 959516615c string exceptions; how quaint 2010-10-31 17:59:20 +00:00
Benjamin Peterson d094efd8b7 cleanup resources in test_smtplib #10264 2010-10-31 17:15:42 +00:00
Giampaolo Rodolà 977c707b42 Fix issue 6706: adds new handle_accepted() method to asyncore.dispatcher 2010-10-04 21:08:36 +00:00
Richard Jones 6a9e6bbf1a fix test_smtplib/test_smtpd collision through pre-loaded reply data in mock_socket 2010-08-04 12:27:36 +00:00
Richard Jones 64b02de010 improvements to test_smtplib per issue2423
merged the socket mock introduced in test_smtpd
2010-08-03 06:39:33 +00:00
Giampaolo Rodolà d930b63583 Merged revisions 80882 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80882 | giampaolo.rodola | 2010-05-06 22:19:32 +0200 (gio, 06 mag 2010) | 1 line

  adds handle_error(self):raise to test modules using asyncore to provide a clearer error message in case something goes wrong
........
2010-05-06 20:21:57 +00:00
Antoine Pitrou 043bad00bc Merged revisions 80669 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80669 | antoine.pitrou | 2010-05-01 01:08:48 +0200 (sam., 01 mai 2010) | 4 lines

  Issue #8576: Remove use of find_unused_port() in test_smtplib and
  test_multiprocessing.  Patch by Paul Moore.
........
2010-04-30 23:20:15 +00:00
Victor Stinner 45df820591 Merged revisions 80552-80556,80564-80566,80568-80571 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80552 | victor.stinner | 2010-04-27 23:46:03 +0200 (mar., 27 avril 2010) | 3 lines

  Issue #7449, part 1: fix test_support.py for Python compiled without thread
........
  r80553 | victor.stinner | 2010-04-27 23:47:01 +0200 (mar., 27 avril 2010) | 1 line

  Issue #7449, part 2: regrtest.py -j option requires thread support
........
  r80554 | victor.stinner | 2010-04-27 23:51:26 +0200 (mar., 27 avril 2010) | 9 lines

  Issue #7449 part 3, test_doctest: import trace module in test_coverage()

  Import trace module fail if the threading module is missing. test_coverage() is
  only used if test_doctest.py is used with the -c option. This commit allows to
  execute the test suite without thread support.

  Move "import trace" in test_coverage() and use
  test_support.import_module('trace').
........
  r80555 | victor.stinner | 2010-04-27 23:56:26 +0200 (mar., 27 avril 2010) | 6 lines

  Issue #7449, part 4: skip test_multiprocessing if thread support is disabled

  import threading after _multiprocessing to raise a more revelant error message:
  "No module named _multiprocessing". _multiprocessing is not compiled without
  thread support.
........
  r80556 | victor.stinner | 2010-04-28 00:01:24 +0200 (mer., 28 avril 2010) | 8 lines

  Issue #7449, part 5: split Test.test_open() of ctypes/test/test_errno.py

   * Split Test.test_open() in 2 functions: test_open() and test_thread_open()
   * Skip test_open() and test_thread_open() if we are unable to find the C
     library
   * Skip test_thread_open() if thread support is disabled
   * Use unittest.skipUnless(os.name == "nt", ...) on test_GetLastError()
........
  r80564 | victor.stinner | 2010-04-28 00:59:35 +0200 (mer., 28 avril 2010) | 4 lines

  Issue #7449, part 6: fix test_hashlib for missing threading module

  Move @test_support.reap_thread decorator from test_main() to test_threaded_hashing().
........
  r80565 | victor.stinner | 2010-04-28 01:01:29 +0200 (mer., 28 avril 2010) | 6 lines

  Issue #7449, part 7: simplify threading detection in test_capi

   * Skip TestPendingCalls if threading module is missing
   * Test if threading module is present or not, instead of test the presence of
     _testcapi._test_thread_state
........
  r80566 | victor.stinner | 2010-04-28 01:03:16 +0200 (mer., 28 avril 2010) | 4 lines

  Issue #7449, part 8: don't skip the whole test_asynchat if threading is missing

  TestFifo can be executed without the threading module
........
  r80568 | victor.stinner | 2010-04-28 01:14:58 +0200 (mer., 28 avril 2010) | 6 lines

  Issue #7449, part 9: fix test_xmlrpclib for missing threading module

   * Skip testcases using threads if threading module is missing
   * Use "http://" instead of URL in ServerProxyTestCase if threading is missing
     because URL is not set in this case
........
  r80569 | victor.stinner | 2010-04-28 01:33:58 +0200 (mer., 28 avril 2010) | 6 lines

  Partial revert of r80556 (Issue #7449, part 5, fix ctypes test)

  Rewrite r80556: the thread test have to be executed just after the test on
  libc_open() and so the test cannot be splitted in two functions (without
  duplicating code, and I don't want to duplicate code).
........
  r80570 | victor.stinner | 2010-04-28 01:51:16 +0200 (mer., 28 avril 2010) | 8 lines

  Issue #7449, part 10: test_cmd imports trace module using test_support.import_module()

  Use test_support.import_module() instead of import to raise a SkipTest
  exception if the import fail. Import trace fails if the threading module is
  missing.

  See also part 3: test_doctest: import trace module in test_coverage().
........
  r80571 | victor.stinner | 2010-04-28 01:55:59 +0200 (mer., 28 avril 2010) | 6 lines

  Issue #7449, last part (11): fix many tests if thread support is disabled

   * Use try/except ImportError or test_support.import_module() to import thread
     and threading modules
   * Add @unittest.skipUnless(threading, ...) to testcases using threads
........
2010-04-28 22:31:17 +00:00
Antoine Pitrou c3d47724c1 Merged revisions 75849 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75849 | antoine.pitrou | 2009-10-27 20:47:30 +0100 (mar., 27 oct. 2009) | 3 lines

  Suppress transient refleaks in test_smtplib.
........
2009-10-27 19:49:45 +00:00
R. David Murray 23ddc0eae3 Merged revisions 73022 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73022 | r.david.murray | 2009-05-29 13:31:05 -0400 (Fri, 29 May 2009) | 2 lines

  Refactor test parameterization to resolve update timing problem.
........
2009-05-29 18:03:16 +00:00