diff --git a/rhodecode/config/deployment.ini_tmpl b/rhodecode/config/deployment.ini_tmpl --- a/rhodecode/config/deployment.ini_tmpl +++ b/rhodecode/config/deployment.ini_tmpl @@ -24,6 +24,8 @@ pdebug = false #smtp_port = #smtp_use_tls = false #smtp_use_ssl = true +# Specify available auth parameters here (e.g. LOGIN PLAIN CRAM-MD5, etc.) +#smtp_auth = [server:main] ##nr of threads to spawn diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -356,9 +356,10 @@ def send_email(recipients, subject, body tls = str2bool(email_config.get('smtp_use_tls')) ssl = str2bool(email_config.get('smtp_use_ssl')) debug = str2bool(config.get('debug')) + smtp_auth = email_config.get('smtp_auth') try: - m = SmtpMailer(mail_from, user, passwd, mail_server, + m = SmtpMailer(mail_from, user, passwd, mail_server,smtp_auth, mail_port, ssl, tls, debug=debug) m.send(recipients, subject, body) except: diff --git a/rhodecode/lib/smtp_mailer.py b/rhodecode/lib/smtp_mailer.py --- a/rhodecode/lib/smtp_mailer.py +++ b/rhodecode/lib/smtp_mailer.py @@ -36,6 +36,7 @@ from email.utils import formatdate from email import encoders + class SmtpMailer(object): """SMTP mailer class @@ -49,7 +50,7 @@ class SmtpMailer(object): """ - def __init__(self, mail_from, user, passwd, mail_server, + def __init__(self, mail_from, user, passwd, mail_server,smtp_auth, mail_port=None, ssl=False, tls=False, debug=False): self.mail_from = mail_from @@ -60,6 +61,7 @@ class SmtpMailer(object): self.ssl = ssl self.tls = tls self.debug = debug + self.auth = smtp_auth def send(self, recipients=[], subject='', body='', attachment_files=None): @@ -78,6 +80,8 @@ class SmtpMailer(object): smtp_serv.set_debuglevel(1) smtp_serv.ehlo() + if self.auth: + smtp_serv.esmtp_features["auth"] = self.auth #if server requires authorization you must provide login and password #but only if we have them