Skip to content

Commit

Permalink
Add missing credentials and tls configuration to error email handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Zharktas committed Mar 29, 2019
1 parent c87d021 commit e3d7166
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ckan/config/middleware/flask_app.py
Expand Up @@ -474,11 +474,17 @@ def filter(self, log_record):
return True

mailhost = tuple(config.get('smtp.server', 'localhost').split(":"))
credentials = None
if config.get('smtp.user'):
credentials = (config.get('smtp.user'), config.get('smtp.password'))
secure = () if asbool(config.get('smtp.starttls')) else None
mail_handler = SMTPHandler(
mailhost=mailhost,
fromaddr=config.get('error_email_from'),
toaddrs=[config.get('email_to')],
subject='Application Error'
subject='Application Error',
credentials=credentials,
secure=secure
)

mail_handler.setFormatter(logging.Formatter('''
Expand Down

0 comments on commit e3d7166

Please sign in to comment.