Opened 15 years ago

Closed 4 years ago

#13570 closed Bug (duplicate)

SMTP backend should try harder to figure out the local host name

Reported by: Jacob Owned by: sernin
Component: Core (Mail) Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Django's SMTP backend sets the local_hostname argument to smtplib.SMTP by calling socket.getfqdn() (via django.core.mail.utils.DNS_NAME, which caches that result). smtplib itself uses a slightly more robust method (see smtplib around line 245) if local_hostname isn't given.

In certain circumstances this can mean that sending mail through smtplib directly works, but sending it via django.core.mail fails.

We could solve this by just passing local_hostname=None, but that'd result in a DNS lookup every time we send email, which is silly (and which is why we're caching it in the first place).

So, DNS_NAME should use similar logic to smtplib to try harder to get the DNS hostname.

Attachments (1)

ticket13570.diff (823 bytes ) - added by sernin 14 years ago.

Download all attachments as: .zip

Change History (12)

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

Triage Stage: UnreviewedAccepted

comment:2 by sernin, 14 years ago

Owner: changed from nobody to sernin
Status: newassigned

by sernin, 14 years ago

Attachment: ticket13570.diff added

comment:3 by sernin, 14 years ago

Has patch: set

comment:4 by anonymous, 14 years ago

Forgot to comment -- but trivial patch attached, copies the logic from python's standard smtplib. Should be ready for checkin but this is my first contribution so I'll leave this as-is (Accepted, has_patch).

comment:5 by Claude Paroz, 14 years ago

Triage Stage: AcceptedReady for checkin

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

Needs tests: set
Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

Sorry - but this isn't RFC.

It doesn't contain a test case, and it doesn't contain a compelling argument for why tests aren't plausible. It doesn't even contain a clear description of why the change is needed other than suggesting "certain circumstances" under which it will be needed.

It also seems to assume that the result of socket.gethostbyname(socket.gethostname()) will be an IPv6 address, which I'm pretty sure isn't correct.

comment:7 by Julien Phalip, 14 years ago

Severity: Normal
Type: Bug

comment:8 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

comment:11 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:12 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:13 by Sam Kuffer, 4 years ago

Resolution: duplicate
Status: assignedclosed

Duplicate of #6989

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