Ticket #17471: smtp_patch.txt

File smtp_patch.txt, 1.1 KB (added by dje, 4 years ago)

svn diff patch

Line 
1Index: django/core/mail/backends/smtp.py
2===================================================================
3--- django/core/mail/backends/smtp.py   (revision 17282)
4+++ django/core/mail/backends/smtp.py   (working copy)
5@@ -44,12 +44,13 @@
6         try:
7             # If local_hostname is not specified, socket.getfqdn() gets used.
8             # For performance, we use the cached FQDN for local_hostname.
9-            self.connection = smtplib.SMTP(self.host, self.port,
10+            if self.use_tls:
11+                self.connection = smtplib.SMTP_SSL(self.host, self.port,
12                                            local_hostname=DNS_NAME.get_fqdn())
13-            if self.use_tls:
14-                self.connection.ehlo()
15-                self.connection.starttls()
16-                self.connection.ehlo()
17+            else:
18+                self.connection = smtplib.SMTP(self.host, self.port,
19+                                           local_hostname=DNS_NAME.get_fqdn())
20+
21             if self.username and self.password:
22                 self.connection.login(self.username, self.password)
23             return True
Back to Top