Commit a0098b06 authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[cubicweb/cwconfig] authenticated SMTP outgoing email

--HG--
branch : 3.26
parent 7f8550e3f8a2
......@@ -939,6 +939,16 @@ class CubicWebConfiguration(CubicWebNoAppConfiguration):
'help': 'listening port of the SMTP mail server',
'group': 'email', 'level': 1,
}),
('smtp-username',
{'default': '',
'help': 'username for SMTP mail server if auth is required',
'group': 'email', 'level': 2,
}),
('smtp-password',
{'default': '',
'help': 'password for SMTP mail server if auth is required',
'group': 'email', 'level': 2,
}),
('sender-name',
{'type' : 'string',
'default': Method('default_instance_id'),
......@@ -1332,12 +1342,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_LOCK.acquire()
try:
try:
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