#6989: Inability to define DNS_NAME in django.core.mail results in e-mail
messages
being rejected or marked as spam
-------------------------------------+-------------------------------------
Reporter: Franklin | Owner: heathervm
Type: Bug | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: local_hostname, | Triage Stage: Accepted
DNS_NAME, CachedDnsName, smtplib, |
SMTPConnection |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Diederik van der Boor):
Python's smtplib.SMTP code works around this problem with a fallback to
the IP address::
{{{
# RFC 2821 says we should use the fqdn in the EHLO/HELO verb,
and
# if that can't be calculated, that we should use a domain
literal
# instead (essentially an encoded IP address like [A.B.C.D]).
fqdn = socket.getfqdn()
if '.' in fqdn:
self.local_hostname = fqdn
else:
# We can't find an fqdn hostname, so use a domain literal
addr = '127.0.0.1'
try:
addr = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
pass
self.local_hostname = '[%s]' % addr
}}}
This is overwritten as Django's
`django.core.mail.backens.smtp.EmailBackend` overwrites this to:
`connection_params = {'local_hostname': DNS_NAME.get_fqdn()}`
One possible extra fix would be to support the same fallback to IP-
addresses when there is no dot in the hostname, just like
`smtplib.SMTP.open()` does.
--
Ticket URL: <https://code.djangoproject.com/ticket/6989#comment:19>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.f727f872ac661de3f94f189d55348818%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.