diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 97b7ac6..7da8fa6 100644
|
a
|
b
|
EMAIL_HOST_USER = ''
|
| 176 | 176 | EMAIL_HOST_PASSWORD = '' |
| 177 | 177 | EMAIL_USE_TLS = False |
| 178 | 178 | |
| | 179 | # Hostname to send in the EHLO message to the SMTP server. |
| | 180 | EMAIL_LOCAL_HOSTNAME = '' |
| | 181 | |
| 179 | 182 | # List of strings representing installed apps. |
| 180 | 183 | INSTALLED_APPS = () |
| 181 | 184 | |
diff --git a/django/core/mail/backends/smtp.py b/django/core/mail/backends/smtp.py
index bb184ab..9b7304d 100644
|
a
|
b
|
class EmailBackend(BaseEmailBackend):
|
| 14 | 14 | A wrapper that manages the SMTP network connection. |
| 15 | 15 | """ |
| 16 | 16 | def __init__(self, host=None, port=None, username=None, password=None, |
| 17 | | use_tls=None, fail_silently=False, **kwargs): |
| | 17 | use_tls=None, fail_silently=False, from_host=None, **kwargs): |
| 18 | 18 | super(EmailBackend, self).__init__(fail_silently=fail_silently) |
| 19 | 19 | self.host = host or settings.EMAIL_HOST |
| 20 | 20 | self.port = port or settings.EMAIL_PORT |
| 21 | 21 | self.username = username or settings.EMAIL_HOST_USER |
| 22 | 22 | self.password = password or settings.EMAIL_HOST_PASSWORD |
| | 23 | |
| | 24 | # If from_host and settings.EMAIL_FROM_HOST are not specified, |
| | 25 | # socket.getfqdn() gets used. For performance, we use the cached |
| | 26 | # FQDN for from_host. |
| | 27 | self.from_host = from_host or \ |
| | 28 | settings.EMAIL_LOCAL_HOSTNAME or \ |
| | 29 | DNS_NAME.get_fqdn() |
| | 30 | |
| 23 | 31 | if use_tls is None: |
| 24 | 32 | self.use_tls = settings.EMAIL_USE_TLS |
| 25 | 33 | else: |
| … |
… |
class EmailBackend(BaseEmailBackend):
|
| 36 | 44 | # Nothing to do if the connection is already open. |
| 37 | 45 | return False |
| 38 | 46 | try: |
| 39 | | # If local_hostname is not specified, socket.getfqdn() gets used. |
| 40 | | # For performance, we use the cached FQDN for local_hostname. |
| 41 | 47 | self.connection = smtplib.SMTP(self.host, self.port, |
| 42 | | local_hostname=DNS_NAME.get_fqdn()) |
| | 48 | local_hostname=self.from_host) |
| 43 | 49 | if self.use_tls: |
| 44 | 50 | self.connection.ehlo() |
| 45 | 51 | self.connection.starttls() |
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index 8bf0a4e..47e54d4 100644
|
a
|
b
|
Whether to use a TLS (secure) connection when talking to the SMTP server.
|
| 882 | 882 | |
| 883 | 883 | .. setting:: FILE_CHARSET |
| 884 | 884 | |
| | 885 | EMAIL_LOCAL_HOSTNAME |
| | 886 | -------------------- |
| | 887 | |
| | 888 | Default: ``''`` (Empty string) |
| | 889 | |
| | 890 | The hostname to send to the SMTP server in the EHLO command. If unset, a |
| | 891 | cached local DNS name from socket.getfqdn() is used. |
| | 892 | |
| 885 | 893 | FILE_CHARSET |
| 886 | 894 | ------------ |
| 887 | 895 | |
diff --git a/docs/topics/email.txt b/docs/topics/email.txt
index ea62120..892ab23 100644
|
a
|
b
|
Mail is sent using the SMTP host and port specified in the
|
| 30 | 30 | :setting:`EMAIL_HOST_USER` and :setting:`EMAIL_HOST_PASSWORD` settings, if |
| 31 | 31 | set, are used to authenticate to the SMTP server, and the |
| 32 | 32 | :setting:`EMAIL_USE_TLS` setting controls whether a secure connection is used. |
| | 33 | :setting:`EMAIL_LOCAL_HOSTNAME` specifies the hostname to be sent in the |
| | 34 | SMTP EHLO command |
| 33 | 35 | |
| 34 | 36 | .. note:: |
| 35 | 37 | |
| … |
… |
SMTP backend
|
| 417 | 419 | This is the default backend. E-mail will be sent through a SMTP server. |
| 418 | 420 | The server address and authentication credentials are set in the |
| 419 | 421 | :setting:`EMAIL_HOST`, :setting:`EMAIL_PORT`, :setting:`EMAIL_HOST_USER`, |
| 420 | | :setting:`EMAIL_HOST_PASSWORD` and :setting:`EMAIL_USE_TLS` settings in your |
| 421 | | settings file. |
| | 422 | :setting:`EMAIL_LOCAL_HOSTNAME`, :setting:`EMAIL_HOST_PASSWORD` and |
| | 423 | :setting:`EMAIL_USE_TLS` settings in your settings file. |
| 422 | 424 | |
| 423 | 425 | The SMTP backend is the default configuration inherited by Django. If you |
| 424 | 426 | want to specify it explicitly, put the following in your settings:: |