Opened 14 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)
Change History (12)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 14 years ago
Attachment: | ticket13570.diff added |
---|
comment:3 by , 14 years ago
Has patch: | set |
---|
comment:4 by , 14 years ago
comment:5 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:6 by , 14 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Ready for checkin → Accepted |
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 , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
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).