Skip to content

Commit

Permalink
Merge pull request #4711 from Zharktas/add_credentials_error_email_ha…
Browse files Browse the repository at this point in the history
…ndler

Add missing credentials and tls configuration to error email handler
  • Loading branch information
David Read committed May 28, 2019
2 parents 23cb420 + e3d7166 commit 236f245
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ckan/config/middleware/flask_app.py
Expand Up @@ -478,11 +478,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 236f245

Please sign in to comment.