| Age | Commit message (Collapse) | Author |
|
Thanks Kasper Dupont for the report, and Jacob Walls and Natalia Bidart
for reviews.
|
|
Versions of Python prior to 3.15 would incorrectly encode non-ASCII
email addresses using rfc2047, resulting in undeliverable email. The
SMTP EmailBackend detects and prevents that (#35713). Python 3.15 fixes
that behavior (CPython issue gh-122476).
Updated test_rejects_non_ascii_local_part() to feature-detect the fix
(in case it is backported) and check for a representative section of
the Python error message if so; otherwise test for the SMTP EmailBackend
workaround.
Updated comments to clarify need and requirement.
|
|
See DEP 0018.
Added:
* MAILERS setting.
* django.core.mail.mailers dict-like EmailBackend factory.
* `using` argument to mail sending APIs.
* `sent_using` attribute to mail.outbox messages in locmem backend.
* MAILERS in startproject settings template, set to console backend.
* AdminLogHandler.using argument.
* BrokenLinkEmailsMiddleware.send_mail() method.
Updated:
* BaseEmailBackend to track the MAILERS alias used to construct it, and
to report errors for unknown kwargs (OPTIONS).
* EmailBackend implementations to initialize from kwargs (OPTIONS) only
when MAILERS is being used.
* smtp.EmailBackend to require `host` option and to default `port`
option based on SSL/TLS options.
* SimpleTestCase setup to substitute the locmem backend for all defined
MAILERS configurations.
* Django's tests that send mail to define MAILERS.
Deprecated:
* EMAIL_BACKEND and other backend-related EMAIL_* settings.
* mail.get_connection().
* The `connection`, `fail_silently`, `auth_user`, and `auth_password`
arguments to mail functions.
* The EmailMessage.connection attribute.
* BaseEmailBackend support for `fail_silently`. Backends that support
fail_silently (SMTP, console, file) now implement it directly.
* AdminEmailHandler.email_backend argument.
Removed undocumented features without deprecation:
* EmailMessage.get_connection() method. (send() now raises an error if a
subclass has attempted to override it.)
* EmailMessage.send() no longer sets self.connection to the connection
used for sending. (It still _uses_ a pre-existing self.connection.)
* AdminEmailHandler.connection() method. (Init now raises an error if a
subclass has attempted to override it.)
Thanks to Natalia Bidart for shepherding DEP 0018 and for extensive
reviews and suggestions on the implementation.
Thanks to Jacob Rief for the initial implementation and multiple
iterations while refining the design.
Co-authored-by: Jacob Rief <jacob.rief@gmail.com>
|
|
Reworked tests/mail/test_backends.py so that cases covering functional
behavior don't depend on EMAIL_BACKEND or other EMAIL_* settings. (But
kept unchanged existing tests to verify backend instance properties are
initialized from EMAIL_* settings.)
Most backend behavior tests had implicitly relied on email settings
overrides in test setup (e.g., to use an emulated SMTP server). They
either used mail.get_connection(...) or directly constructed a backend
class instance with the specific attributes being tested, relying on
the settings overrides to initialize other required attributes. That
approach won't work after those settings are deprecated as part of
EMAIL_PROVIDERS.
Instead, replaced backend construction in "functional" tests with new
SharedEmailBackendTests.create_backend() which constructs the testable
backend instance with _all_ options needed to avoid global settings.
Tests to verify the settings are read correctly continue to directly
construct backend instances, without using create_backend().
|
|
Replaced TypeError in `os.path.abspath(None)` with ImproperlyConfigured
error when settings.EMAIL_FILE_PATH is required but missing.
|
|
Added tests for:
* BaseEmailBackend class.
* EmailBackend support for fail_silently arg and unknown kwargs.
* File backend support for EMAIL_FILE_PATH setting.
* File backend configuration error reporting (where possible).
* SMTP backend support for EMAIL_HOST and EMAIL_PORT settings.
* SMTP backend use of ssl_certfile, ssl_keyfile, timeout options.
* send_mail() return value.
* send_mass_mail() basic behavior.
* send_mail() and send_mass_mail() support for auth_user, auth_password,
and fail_silently args.
* get_connection() support for EMAIL_BACKEND setting and backend-specfic
kwargs.
|
|
* Removed unnecessary empty username/password args and unnecessary test
email content.
* Replaced monkeypatching with mock.patch. Minimized scope of patches.
* Added missing assertions in some tests.
* Cleaned up uses of assertTrue() and assertFalse().
* Removed implicit assumption in LocmemBackendTests that mail is always
sent by the locmem backend during tests.
* Made FileBackendTests tmp_dir cleanup more robust, and added helpers
to simplify test cases.
* Split FileBackendTests.test_sessions() into three distinct cases (and
removed unrelated, duplicative verification of message content).
* Used mock to simplify and improve accuracy of SMTP AUTH test.
* Replaced `get_connection("mail.custombackend.EmailBackend")` with
direct `custombackend.EmailBackend()` construction to avoid soon-to-
be-deprecated usage of `get_connection(backend_path)` in cases that
aren't trying to test creating a connection from an import path.
|
|
* Renamed shared backend test case class to SharedEmailBackendTests,
to avoid confusion with tests for the BaseEmailBackend.
* Used consistent module references to mail functions (removed `mail.`
from most uses; kept it for `mail.get_connection()`).
* Used consistent `backend` variable name for EmailBackend instances in
backend tests (matching most SMTP tests, replacing `connection` and
`conn` in other tests).
* Renamed some test cases for clarity.
* Removed some unnecessary docstrings from test cases.
* Reformatted some docstrings with nearby edits.
|
|
Moved tests for specific email backends from tests/mail/tests.py
to test_backends.py to reduce file size and discourage adding
non-backend-specific tests to BaseEmailBackendTests.
|