Ticket #13142: smtp_add_ssl.diff

File smtp_add_ssl.diff, 1.6 KB (added by serg.partizan@…, 14 years ago)

Patch that adds support for ssl connections

  • smtp.py

    old new  
    1313    A wrapper that manages the SMTP network connection.
    1414    """
    1515    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):
    1717        super(EmailBackend, self).__init__(fail_silently=fail_silently)
    1818        self.host = host or settings.EMAIL_HOST
    1919        self.port = port or settings.EMAIL_PORT
    2020        self.username = username or settings.EMAIL_HOST_USER
    2121        self.password = password or settings.EMAIL_HOST_PASSWORD
     22        if use_ssl is None:
     23            self.use_ssl = settings.EMAIL_USE_SSL
    2224        if use_tls is None:
    2325            self.use_tls = settings.EMAIL_USE_TLS
    2426        else:
     
    3739        try:
    3840            # If local_hostname is not specified, socket.getfqdn() gets used.
    3941            # 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())
    4248            if self.use_tls:
    4349                self.connection.ehlo()
    4450                self.connection.starttls()
Back to Top