Commit Graph

61 Commits

Author SHA1 Message Date
za 321e94fa41 Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings. 2016-11-10 21:30:21 -05:00
Claude Paroz 8858631498 Fixed #27469 -- Prevented sending email to empty addresses
Thanks Jarek Glowacki for the report.
2016-11-10 19:47:02 +01:00
Jon Dufresne 9b9c8c4a81 Fixed #27368 -- Modifed BaseEmailBackend.__enter__() to close the connection if an exception occurs.
Fixes unclosed socket ResourceWarning in mail test.

Thanks Claude Paroz for the review.
2016-10-21 05:59:07 -07:00
Claude Paroz 458e2fbfcc Fixed #27333 -- Prevented BASE64 encoding in message.as_string() on Python 3
Thanks Tim Graham for the review.
2016-10-12 20:48:09 +02:00
Tim Graham b2f9db1637 Removed redundant usage of assertNotIn() in a mail test.
The Content-Transfer-Encoding header won't be repeated, so checking
the header is sufficient.
2016-10-12 14:26:17 -04:00
Tim Graham f6fe8ecc10 Refs #27210 -- Fixed isolation of test_fail_silently_on_connection_error.
The test wouldn't pass if a mail server is running on the system.
2016-09-30 12:22:52 -04:00
Vesteinn Snaebjarnarson 602bffe758 Fixed #27210 -- Allowed SMTPBackend to fail silently on a socket connection error. 2016-09-27 14:34:49 -04:00
levental 42dc9d0400 Fixed #26210 -- Prevented SMTP backend from trying to send mail after a connection failure. 2016-09-21 16:45:10 -04:00
Claude Paroz fe252c0a5a Fixed #27131 -- Passed proper string type to SMTP connection login
Passing an Unicode string on Python 2 was crashing the connection.
Thanks slavugan@gmail.com for the report, and Tim Graham for the review.
2016-08-31 09:00:41 +02:00
Michael Schwarz 72d541b61c Fixed #27007 -- Handled non-UTF-8 bytes objects for text/* attachments.
The fallback logic which allows non-UTF-8 encoded files to be passed to
attach_file() even when a `text/*` mime type has been specified is
moved to attach(). Both functions now fall back to a content type of
`application/octet-stream`.

A side effect is that a file's content is decoded in memory instead of
opening it in text mode and reading it into a string.

Some mimetype-related logic in _create_attachment() has become
obsolete as the code moved from attach_file() to attach() already
handles this.
2016-08-12 16:35:09 -04:00
Antoine Fontaine 004ba05bca Fixed #27036 -- Made locmem email backend's send_messages() accept generators. 2016-08-08 20:13:29 -04:00
Michael Schwarz 6fe391d437 Refs #27007 -- Enhanced mail text attachment test
The test now also checks whether the sent message's attachment has the expected
name, content and mime type.
2016-08-07 19:18:08 +02:00
Claude Paroz 04b7b28812 Fixed #26802 -- Prevented crash when attaching bytes as text message
Thanks Tim Graham for the review.
2016-07-08 11:58:05 +02:00
Jon Dufresne 4f336f6652 Fixed #26747 -- Used more specific assertions in the Django test suite. 2016-06-16 14:19:18 -04:00
Simon Charette 271581df60 Refs #26712 -- Removed workarounds for PostgreSQL queries on TIME_ZONE changes. 2016-06-06 11:26:21 -04:00
Anton I. Sipos c3495bb984 Fixed #12666 -- Added EMAIL_USE_LOCALTIME setting.
When EMAIL_USE_LOCALTIME=True, send emails with a Date header
in the local time zone.
2016-06-04 09:55:50 -04:00
Sergei Maertens ec009ef1d8 Fixed #25986 -- Fixed crash sending email with non-ASCII in local part of the address.
On Python 3, sending emails failed for addresses containing non-ASCII
characters due to the usage of the legacy Python email.utils.formataddr()
function. This is fixed by using the proper Address object on Python 3.
2016-05-06 14:34:11 -04:00
Claude Paroz 836d475afe Fixed #22561 -- Prevented too long lines in email messages
Thanks NotSqrt for the excellent report and Tim Graham for the review.
2016-04-19 09:35:24 +02:00
Tim Graham 92053acbb9 Fixed E128 flake8 warnings in tests/. 2016-04-08 10:12:33 -04:00
Hasan 253adc2b8a Refs #26022 -- Used context manager version of assertRaisesMessage in tests. 2016-01-29 13:03:39 -05:00
Hasan 3d0dcd7f5a Refs #26022 -- Used context manager version of assertRaises in tests. 2016-01-29 12:32:18 -05:00
Dražen Odobašić b1e33ceced Fixed #23395 -- Limited line lengths to 119 characters. 2015-09-12 11:40:50 -04:00
Konrad Świat c6da621def Fixed #24623 -- Fixed EmailMessage.attach_file() with text files on Python 3.
Thanks tkrapp for the report and Tim Graham for the review.
2015-07-25 07:42:30 -04:00
Shai Berger 071801ccff Cleanup: Removed the try-except-fail antipattern from tests
Found cases where testing code was doing

    try:
        whatever
    except (some excption type):
        self.fail("exception shouldn't be thrown")

replaced it with just

    whatever

as this makes the unexpected errors easier to debug, and the tests
would fail just as much and aren't rendered less readable.

Thanks Markus Holtermann for review
2015-06-05 12:57:20 +03:00
Tim Graham 7d97c5745e Refs #23763 -- Fixed SMTPServer Python 3.5 deprecation warning in mail test. 2015-05-18 09:48:25 -04:00
medmunds 5993b52e6d Fixed #24416 -- Added support for lazy email addresses. 2015-03-13 12:33:49 -04:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
darkryder 9ec8aa5e5d Fixed #24149 -- Normalized tuple settings to lists. 2015-02-03 14:59:45 -05:00
Diego Guimarães e32a8a99d9 Refs #23947 -- Isolated a mail test. 2014-12-06 12:06:06 -05:00
Martin Blech e023ceb453 Fixed #23910 -- Added reply_to parameter to EmailMessage
Thanks to Berker Peksag and Tim Graham for the review and suggestions.
2014-11-28 06:00:06 -05:00
Martin Blech abf87333a1 Fixed #23924 -- Made EmailMessage raise TypeError for type checks 2014-11-27 18:43:45 -05:00
Thomas Chaumeny d89f56dc4d Fixed #21281 -- Made override_settings act at class level when used as a TestCase decorator. 2014-11-03 14:14:39 -05:00
Berker Peksag f7969b0920 Fixed #23620 -- Used more specific assertions in the Django test suite. 2014-11-03 11:56:37 -05:00
Simon Charette f6c208d95c Fixed a flake8 warning. 2014-10-15 16:36:11 -04:00
Florian Apolloner 8d789449c7 Fixed #23063 -- Convert \n and \r to \r\n when using the SMTP backend as per RFC. 2014-10-12 22:01:24 +02:00
José Padilla 5472d18e31 Fixed #23461 -- Added EMAIL_TIMEOUT setting 2014-09-13 09:33:21 -04:00
Andi Albrecht 00535e8e6b Fixed #20743 -- Added support for keyfile/certfile in SMTP connections.
Thanks jwmayfield, serg.partizan, and Wojciech Banaś for work on the patch.
2014-09-10 11:14:20 -04:00
Claude Paroz e520a73eee Harmonized some PEP 0263 coding preambles 2014-05-15 19:58:41 +02:00
Daniel Neuhäuser 4aa80149e7 Fixed #22327 -- Turned BaseEmailBackend into a context manager
Changed the BaseEmailBackend to allow usage as context manager to open
and close connections.
2014-03-31 14:08:51 -04:00
Alex Gaynor 778ce245dd Corrected many style guide violations that the newest version of flake8 catches 2014-03-30 12:11:05 -07:00
Rodolfo Carvalho 0d91225892 Fixed many typos in comments and docstrings.
Thanks Piotr Kasprzyk for help with the patch.
2014-03-03 07:38:09 -05:00
Marc Tamlyn 22198e6ce5 Be more careful about closing connections in mail tests. 2014-01-12 23:39:44 +00:00
Marc Tamlyn 9d2c5b0420 Undelete the `return True` removed in 4e0a2fe.
This is quite important otherwise we don't close our connections to the
SMTP server.
2014-01-12 23:38:28 +00:00
Florian Apolloner c988745cca Changed console and filebackend to use msg.as_bytes to output the data as it would get send via smtp. 2013-12-30 23:46:05 +01:00
Florian Apolloner 5dfd824d38 Introduced as_bytes for SafeMIMEText (and other SafeMIME-classes).
This is to provide a consistent interface (namely bytes) for the smtp
backend which after all sends bytes over the wire; encoding with as_string
yields different results since mails as unicode are not really specified.

as_string stays for backwardscompatibilty mostly and some debug outputs.
But keep in mind that the output doesn't match as_bytes!
2013-12-28 18:35:17 +01:00
Aymeric Augustin e32095616c Imported override_settings from its new location. 2013-12-23 21:37:56 +01:00
Loic Bistuer 6685713869 Fixed E127 pep8 warnings. 2013-12-14 11:59:15 -05:00
Claude Paroz 3afde36d03 Undelete the login() call inadvertantly removed in 4e0a2fe59c
Refs #21271.
2013-10-25 11:23:19 +02:00
SusanTan 4e0a2fe59c Fixed #21271 -- Added timeout parameter to SMTP EmailBackend.
Thanks Tobias McNulty and Tim Graham for discussions and code review.
Thanks Andre Cruz the suggestion and initial patch.
2013-10-24 20:38:00 -04:00
Alasdair Nicol b289fcf1bf Fixed #21288 -- Fixed E126 pep8 warnings 2013-10-21 08:31:30 -04:00