diff --git a/tests/test_misc.py b/tests/test_misc.py index 570b6407b..758d0928d 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -4,6 +4,8 @@ import json import pytest import os import pickle +import pwd +import socket import re import time import datetime @@ -309,7 +311,7 @@ def test_email_from(emails): pub = create_temporary_pub() send_email('test', mail_body='Hello', email_rcpt='test@localhost', want_html=False) assert emails.count() == 1 - assert emails.emails['test']['from'] == 'noreply@entrouvert.com' + assert emails.emails['test']['from'] == '%s@%s' % (pwd.getpwuid(os.getuid())[0], socket.getfqdn()) pub.cfg['emails'] = {'from': 'foo@localhost'} send_email('test', mail_body='Hello', email_rcpt='test@localhost', want_html=False) diff --git a/wcs/qommon/emails.py b/wcs/qommon/emails.py index f65e12d7d..a4b6ec0af 100644 --- a/wcs/qommon/emails.py +++ b/wcs/qommon/emails.py @@ -15,6 +15,7 @@ # along with this program; if not, see . import os +import pwd import re from email import encoders @@ -287,7 +288,9 @@ def email(subject, mail_body, email_rcpt, replyto=None, bcc=None, msg['To'] = email_rcpt if not email_from: - email_from = emails_cfg.get('from', 'noreply@entrouvert.com') + email_from = emails_cfg.get('from') + if not email_from: + email_from = '%s@%s' % (pwd.getpwuid(os.getuid())[0], socket.getfqdn()) sitename = get_publisher().get_site_option('global_title', 'variables') if sitename: