Django: Ticket Queryhttps://code.djangoproject.com/query?status=!closed&keywords=~connect&order=priority
The Web framework for perfectionists with deadlines.en-USDjangohttps://www.djangoproject.com/s/img/site/hdr_logo.gifhttps://code.djangoproject.com/query?status=!closed&keywords=~connect&order=priority
Trac 1.2https://code.djangoproject.com/ticket/6989
https://code.djangoproject.com/ticket/6989#6989: Inability to define DNS_NAME in django.core.mail results in e-mail messages being rejected or marked as spamWed, 09 Apr 2008 01:42:11 GMTFranklin<p>
<strong>Summary</strong><br />
Being the case that the application server's hostname may not necessarily be a valid fully qualified domain name (FQDN) the use of socket.getfqdn() in defining DNS_NAME may yield a number of e-mail messages either rejected or marked as spam. Rejection issues arise if settings.EMAIL_USE_TLS is True - meaning smtplib.ehlo() will be called - and if a mail server is particularly strict (or misconfigured) and rejects any ehlo command followed by an invalid FQDN. Spam issues arise with DNS_NAME being used as the local_hostname argument to smtplib.SMTP() within the SMTPConnection.open() method, meaning the initial "Received:&#34; e-mail header may be from an invalid FQDN. Further increasing the chance of being marked as spam is DNS_NAME being used by the make_msgid() method, leaving the &#34;Message-ID:" e-mail header ending in an invalid FQDN.
</p>
<p>
<strong>Real World Scenario</strong><br />
A shared server has a hostname, which you may not and can not change, of "star-wars-reference". The socket.getfqdn() method fails to find info on its IP address and by default simply returns said hostname. E-mail is then sent by Django with a Message-ID of "200804....@star-wars-reference" from a server claiming to be "star-wars-reference ([server's IP address])" and is, of course, marked as spam.
</p>
<p>
<strong>Solution</strong><br />
Provide an optional settings variable such as EMAIL_LOCAL_HOSTNAME where Django developers may define a FQDN which maps to their application's server. EMAIL_LOCAL_HOSTNAME will be used by the class defining DNS_NAME in lieu of socket.getfqdn() if EMAIL_LOCAL_HOSTNAME exists in the settings file (this has the added benefit of preventing a call to socket.getfqdn() - further reducing overhead on restarts).
</p>
Resultshttps://code.djangoproject.com/ticket/6989#changelog