Ticket #13142: smtp_add_ssl.diff
File smtp_add_ssl.diff, 1.6 KB (added by , 15 years ago) |
---|
-
smtp.py
old new 13 13 A wrapper that manages the SMTP network connection. 14 14 """ 15 15 def __init__(self, host=None, port=None, username=None, password=None, 16 use_ tls=None, fail_silently=False, **kwargs):16 use_ssl=None, use_tls=None, fail_silently=False, **kwargs): 17 17 super(EmailBackend, self).__init__(fail_silently=fail_silently) 18 18 self.host = host or settings.EMAIL_HOST 19 19 self.port = port or settings.EMAIL_PORT 20 20 self.username = username or settings.EMAIL_HOST_USER 21 21 self.password = password or settings.EMAIL_HOST_PASSWORD 22 if use_ssl is None: 23 self.use_ssl = settings.EMAIL_USE_SSL 22 24 if use_tls is None: 23 25 self.use_tls = settings.EMAIL_USE_TLS 24 26 else: … … 37 39 try: 38 40 # If local_hostname is not specified, socket.getfqdn() gets used. 39 41 # For performance, we use the cached FQDN for local_hostname. 40 self.connection = smtplib.SMTP(self.host, self.port, 41 local_hostname=DNS_NAME.get_fqdn()) 42 if self.use_ssl: 43 self.connection = smtplib.SMTP_SSL(self.host, self.port, 44 local_hostname=DNS_NAME.get_fqdn()) 45 else: 46 self.connection = smtplib.SMTP(self.host, self.port, 47 local_hostname=DNS_NAME.get_fqdn()) 42 48 if self.use_tls: 43 49 self.connection.ehlo() 44 50 self.connection.starttls()