emails: compute default from using local user/hostname (#43496)
This commit is contained in:
parent
dcb3624834
commit
9f0160549c
|
@ -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)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue