Commit 0180b8b0 authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[cubicweb/cwconfig] authenticated SMTP outgoing email

parent 94588f6e828d
......@@ -855,6 +855,16 @@ class CubicWebConfiguration(CubicWebNoAppConfiguration):
'help': 'listening port of the SMTP mail server',
'group': 'email', 'level': 1,
{'default': '',
'help': 'username for SMTP mail server if auth is required',
'group': 'email', 'level': 2,
{'default': '',
'help': 'password for SMTP mail server if auth is required',
'group': 'email', 'level': 2,
{'type' : 'string',
'default': Method('default_instance_id'),
......@@ -1238,12 +1248,15 @@ the repository',
if connection to the smtp server failed, else True.
server, port = self['smtp-host'], self['smtp-port']
smtp_user, smtp_password = self['smtp-user'], self['smtp-password']
if fromaddr is None:
fromaddr = '%s <%s>' % (self['sender-name'], self['sender-addr'])
smtp = SMTP(server, port)
if smtp_user and smtp_password:
smtp.login(smtp_user, smtp_password)
except Exception as ex:
self.exception("can't connect to smtp server %s:%s (%s)",
server, port, ex)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment