Opened 14 years ago

Closed 14 years ago

Last modified 5 years ago

#15042 closed (fixed)

1.2.4 regression: send_mail doesn't access email recipient with no domain

Reported by: net147 Owned by: Łukasz Rekucki
Component: Core (Mail) Version: 1.2
Severity: Keywords: blocker regression send_mail email
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Sending email using django.core.mail.send_mail fails to send to an email recipient that is just the username on the current system (e.g. joe instead of joe@localhost).
This worked fine in Django 1.2.3 but no longer works in Django 1.2.4 (throws a ValueError trying to split the email by @ into name and domain).

Attachments (2)

15043.diff (832 bytes ) - added by Łukasz Rekucki 14 years ago.
Patch against trunk.
ticket15042.diff (38.7 KB ) - added by Łukasz Rekucki 14 years ago.
The right patch against trunk.

Download all attachments as: .zip

Change History (9)

comment:1 by Russell Keith-Magee, 14 years ago

Keywords: blocker added
milestone: 1.3
Triage Stage: UnreviewedAccepted

To clarify - this only affects the SMTP backend. Code was broken by r15006, fixing #14301, because there's no existing test for the behavior described.

Mail tests should probably be backend-duplicated like the tests for cache backends.

comment:2 by Łukasz Rekucki, 14 years ago

Owner: changed from nobody to Łukasz Rekucki

Started refactoring of regressiontests/mail/tests.py. Shouldn't take long.

by Łukasz Rekucki, 14 years ago

Attachment: 15043.diff added

Patch against trunk.

by Łukasz Rekucki, 14 years ago

Attachment: ticket15042.diff added

The right patch against trunk.

comment:3 by Łukasz Rekucki, 14 years ago

Has patch: set

The patch contains:

  • Refactored tests for mail handling:
    • MailTests class contains test cases related to EmailMessage class that don't depend on any backend.
    • BaseEmailBackendTests contains all other tests that involve actually sending any messages.
    • FakeSMTPServer using Python's smptd module for testing the SMTP backend. This runs in another thread for the duration of the testcase.
  • Correct handling of IDN: all headers that contain email addresses must be sanitized properly. Otherwise, the whole header will be encoded as "quoted-printable", thus loosing it's structure. I tried sending some emails to a localy defined IDN and Postfix treats the value in From: =?utf-8?b?ZnLDtm1Aw7bDpMO8LmNvbQ==?= as it was a mailbox name.
  • Some support for non-ASCII characters in local-part of the email (they're encoded as they we're before).
  • A fix and a regression test for this issue.


Note: Backporting to 1.2.X involves moving some code from setUpClass/tearDownClass in SMTPBackendTests to setUp/tearDown. Should I make a seperate patch ?


comment:4 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [15211]) Fixed #15042 -- Ensured that email addresses without a domain can still be mail recipients. Patch also improves the IDN handling introduced by r15006, and refactors the test suite to ensure even feature coverage. Thanks to net147 for the report, and to Łukasz Rekucki for the awesome patch.

comment:5 by Russell Keith-Magee, 14 years ago

(In [15213]) [1.2.X] Fixed #15042 -- Ensured that email addresses without a domain can still be mail recipients. Patch also improves the IDN handling introduced by r15006, and refactors the test suite to ensure even feature coverage. Thanks to net147 for the report, and to Łukasz Rekucki for the awesome patch.

Backport of r15211 from trunk.

comment:6 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

comment:7 by Carlton Gibson <carlton@…>, 5 years ago

Easy pickings: unset
UI/UX: unset

In 1564e42a:

Refs #30512, #15042 -- Added local-only address to sanitize_email() tests cases.

email.headerregistry.parser.get_mailbox() returns a token with a token_type attribute.

If token_type is ’invalid-mailbox’ then RFC violations have been detected. Emails with only the local part, and no domain, are correctly parsed but are marked as ’invalid-mailbox’.

As per #15042, local-only are supported, to enable sending to addresses on localhost.

sanitize_email() does not currently check token_type. This test is added to avoid a regression in case this is revisited in the future.

Note: See TracTickets for help on using tickets.
Back to Top