Added SMTP Auth support
This commit is contained in:
parent
8ca6b4cdb0
commit
054eced7de
@ -39,6 +39,8 @@ def send_email(self: celery.Task, to_name: str, to_addr: str, subject: str, text
|
||||
# Send the message via local SMTP server.
|
||||
try:
|
||||
with smtplib.SMTP(cfg['SMTP_HOST'], cfg['SMTP_PORT'], timeout=cfg['SMTP_TIMEOUT']) as smtp:
|
||||
if cfg.get('SMTP_USERNAME') and cfg.get('SMTP_PASSWORD'):
|
||||
smtp.login(cfg['SMTP_USERNAME'], cfg['SMTP_PASSWORD'])
|
||||
smtp.send_message(msg)
|
||||
except (IOError, OSError) as ex:
|
||||
log.exception('error sending email to %s <%s>, will retry later: %s',
|
||||
|
@ -234,6 +234,8 @@ SUPPORT_ENGLISH = True
|
||||
# Mail options, see pillar.celery.email_tasks.
|
||||
SMTP_HOST = 'localhost'
|
||||
SMTP_PORT = 2525
|
||||
SMTP_USERNAME = ''
|
||||
SMTP_PASSWORD = ''
|
||||
SMTP_TIMEOUT = 30 # timeout in seconds, https://docs.python.org/3/library/smtplib.html#smtplib.SMTP
|
||||
MAIL_RETRY = 180 # in seconds, delay until trying to send an email again.
|
||||
MAIL_DEFAULT_FROM_NAME = 'Blender Cloud'
|
||||
|
Loading…
x
Reference in New Issue
Block a user