From a67cd7ee355ac3009430ea4a49335b3b6d391f0f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 04 2017 13:07:45 +0000 Subject: [PATCH 1/2] Let the error email use the FROM_EMAIL address set in the configuration file Instead of hard-coding nobody@fedoraproject.org. Fixes https://pagure.io/pagure/issue/1701 --- diff --git a/pagure/__init__.py b/pagure/__init__.py index b7b47f4..6a8e79a 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -189,7 +189,8 @@ if APP.config.get('PAGURE_CI_SERVICES'): if not APP.debug: APP.logger.addHandler(pagure.mail_logging.get_mail_handler( smtp_server=APP.config.get('SMTP_SERVER', '127.0.0.1'), - mail_admin=APP.config.get('MAIL_ADMIN', APP.config['EMAIL_ERROR']) + mail_admin=APP.config.get('MAIL_ADMIN', APP.config['EMAIL_ERROR']), + from_email=APP.config.get('FROM_EMAIL', 'pagure@fedoraproject.org') )) # Send classic logs into syslog diff --git a/pagure/mail_logging.py b/pagure/mail_logging.py index b7e1fdb..187cbf8 100644 --- a/pagure/mail_logging.py +++ b/pagure/mail_logging.py @@ -181,12 +181,13 @@ Callstack that lead to the logging statement """ -def get_mail_handler(smtp_server, mail_admin): +def get_mail_handler(smtp_server, mail_admin, from_email): """ Set up the handler sending emails for big exception """ + mail_handler = logging.handlers.SMTPHandler( smtp_server, - 'nobody@fedoraproject.org', + from_email, mail_admin, 'Pagure error') mail_handler.setFormatter(logging.Formatter(MSG_FORMAT)) From 48adce09500da1cdaf5835ba3c54cbafc6f4f835 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 04 2017 13:20:11 +0000 Subject: [PATCH 2/2] Adjust setting up the mail_logging handler in the doc server --- diff --git a/pagure/docs_server.py b/pagure/docs_server.py index d2b5263..172028d 100644 --- a/pagure/docs_server.py +++ b/pagure/docs_server.py @@ -33,7 +33,8 @@ SESSION = pagure.lib.create_session(APP.config['DB_URL']) if not APP.debug: APP.logger.addHandler(pagure.mail_logging.get_mail_handler( smtp_server=APP.config.get('SMTP_SERVER', '127.0.0.1'), - mail_admin=APP.config.get('MAIL_ADMIN', APP.config['EMAIL_ERROR']) + mail_admin=APP.config.get('MAIL_ADMIN', APP.config['EMAIL_ERROR']), + from_email=APP.config.get('FROM_EMAIL', 'pagure@fedoraproject.org') )) # Send classic logs into syslog