Ticket #13142: smtp_ssl_final.diff
File smtp_ssl_final.diff, 3.8 KB (added by , 13 years ago) |
---|
-
docs/topics/email.txt
27 27 :setting:`EMAIL_HOST` and :setting:`EMAIL_PORT` settings. The 28 28 :setting:`EMAIL_HOST_USER` and :setting:`EMAIL_HOST_PASSWORD` settings, if 29 29 set, are used to authenticate to the SMTP server, and the 30 :setting:`EMAIL_USE_TLS` setting controls whether a secure connection is used.30 :setting:`EMAIL_USE_TLS` or :setting:`EMAIL_USE_SSL` setting controls whether a secure connection is used. 31 31 32 32 .. note:: 33 33 -
docs/ref/settings.txt
977 977 978 978 Whether to use a TLS (secure) connection when talking to the SMTP server. 979 979 980 .. setting:: EMAIL_USE_SSL 981 982 EMAIL_USE_SSL 983 ------------- 984 985 Default: ``False`` 986 987 Whether to use a SSL (secure) connection when talking to the SMTP server. 988 989 .. warning:: 990 991 Requirements: Python 2.6 or higher 992 980 993 .. setting:: FILE_CHARSET 981 994 982 995 FILE_CHARSET … … 1027 1040 1028 1041 .. warning:: 1029 1042 1030 1043 **Always prefix the mode with a 0.** 1031 1044 1032 1045 If you're not familiar with file modes, please note that the leading 1033 1046 ``0`` is very important: it indicates an octal number, which is the -
django/conf/global_settings.py
171 171 EMAIL_HOST_USER = '' 172 172 EMAIL_HOST_PASSWORD = '' 173 173 EMAIL_USE_TLS = False 174 EMAIL_USE_SSL = False 174 175 175 176 # List of strings representing installed apps. 176 177 INSTALLED_APPS = () -
django/core/mail/backends/smtp.py
2 2 import smtplib 3 3 import socket 4 4 import threading 5 from sys import version_info 5 6 6 7 from django.conf import settings 7 8 from django.core.mail.backends.base import BaseEmailBackend … … 14 15 A wrapper that manages the SMTP network connection. 15 16 """ 16 17 def __init__(self, host=None, port=None, username=None, password=None, 17 use_ tls=None, fail_silently=False, **kwargs):18 use_ssl=None, use_tls=None, fail_silently=False, **kwargs): 18 19 super(EmailBackend, self).__init__(fail_silently=fail_silently) 19 20 self.host = host or settings.EMAIL_HOST 20 21 self.port = port or settings.EMAIL_PORT … … 26 27 self.password = settings.EMAIL_HOST_PASSWORD 27 28 else: 28 29 self.password = password 30 if use_ssl is None: 31 if settings.EMAIL_USE_SSL and version_info < (2, 6): 32 self.use_ssl = False 33 self.use_ssl = settings.EMAIL_USE_SSL 29 34 if use_tls is None: 30 35 self.use_tls = settings.EMAIL_USE_TLS 31 36 else: … … 44 49 try: 45 50 # If local_hostname is not specified, socket.getfqdn() gets used. 46 51 # For performance, we use the cached FQDN for local_hostname. 47 self.connection = smtplib.SMTP(self.host, self.port, 48 local_hostname=DNS_NAME.get_fqdn()) 52 if self.use_ssl: 53 self.connection = smtplib.SMTP_SSL(self.host, self.port, 54 local_hostname=DNS_NAME.get_fqdn()) 55 else: 56 self.connection = smtplib.SMTP(self.host, self.port, 57 local_hostname=DNS_NAME.get_fqdn()) 49 58 if self.use_tls: 50 59 self.connection.ehlo() 51 60 self.connection.starttls()