Django

Code

Ticket #9488: plain_auth.diff

File plain_auth.diff, 2.2 kB (added by jdemoor, 1 year ago)
  • ../django/core/mail.py

    old new  
    134134                self.connection.starttls() 
    135135                self.connection.ehlo() 
    136136            if self.username and self.password: 
    137                 self.connection.login(self.username, self.password) 
     137                if settings.EMAIL_FORCE_PLAIN_AUTH: 
     138                    # Force plain auth: call ehlo() or helo() first to get the 
     139                    # server's supported methods; then overwrite the results 
     140                    if not (200 <= self.connection.ehlo()[0] <= 299): 
     141                        (code, resp) = self.connection.helo() 
     142                        if not (200 <= code <= 299): 
     143                            raise SMTPHeloError(code, resp) 
     144                    self.connection.esmtp_features["auth"] = "LOGIN PLAIN" 
     145                    self.connection.login(self.username, self.password) 
     146                else: 
     147                    self.connection.login(self.username, self.password) 
    138148            return True 
    139149        except: 
    140150            if not self.fail_silently: 
  • django/conf/global_settings.py

    old new  
    139139EMAIL_HOST_USER = '' 
    140140EMAIL_HOST_PASSWORD = '' 
    141141EMAIL_USE_TLS = False 
     142EMAIL_FORCE_PLAIN_AUTH = False 
    142143 
    143144# List of strings representing installed apps. 
    144145INSTALLED_APPS = () 
  • docs/ref/settings.txt

    old new  
    373373This is only used if ``CommonMiddleware`` is installed (see 
    374374:ref:`topics-http-middleware`). 
    375375 
     376.. setting:: EMAIL_FORCE_PLAIN_AUTH 
     377 
     378EMAIL_FORCE_PLAIN_AUTH 
     379---------------------- 
     380 
     381Default: ``False`` 
     382 
     383Force the transmission of the SMTP password (if any) in plain text. This can be  
     384useful with certain SMTP servers which falsely claim to support CRAM-MD5. 
     385 
     386See also ``EMAIL_HOST_USER`` and ``EMAIL_HOST_PASSWORD``. 
     387 
    376388.. setting:: EMAIL_HOST 
    377389 
    378390EMAIL_HOST