SMTP backend should try harder to figure out the local host name
|Reported by:||jacob||Owned by:||sernin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||yes|
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.
Change History (11)
comment:1 Changed 5 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:2 Changed 5 years ago by sernin
- Owner changed from nobody to sernin
- Status changed from new to assigned
Changed 5 years ago by sernin
comment:6 Changed 4 years ago by russellm
- Needs tests set
- Patch needs improvement set
- Triage Stage changed from Ready for checkin to Accepted