Re: [Django] #6989: Inability to define DNS_NAME in django.core.mail results in e-mail messages being rejected or marked as spam

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #6989: Inability to define DNS_NAME in django.core.mail results in e-mail messages being rejected or marked as spam

Django
#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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #6989: Inability to define DNS_NAME in django.core.mail results in e-mail messages being rejected or marked as spam

Django
#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):

 To add, this issue also happens on Kubernetes pods.

 A standard Pod on Kubernetes has the following configuration:

 **/etc/hosts**

 {{{
 # Kubernetes-managed hosts file.
 127.0.0.1       localhost
 ::1     localhost ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 fe00::0 ip6-mcastprefix
 fe00::1 ip6-allnodes
 fe00::2 ip6-allrouters
 10.244.1.204    examplepod-77f687b9b9-5hlsg
 }}}

 **/etc/resolv.conf**

 {{{
 nameserver 10.96.0.10
 search NAMESPACE.svc.cluster.local svc.cluster.local cluster.local
 options ndots:5
 }}}

 Hence email is submitted using `EHLO examplepod-77f687b9b9-5hlsg` and thus
 triggering spam filtering.

--
Ticket URL: <https://code.djangoproject.com/ticket/6989#comment:20>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.d6481597ff5c6531ee96d506951d2d43%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.