Feature #489 - SMTP configuration options - Acts on feedback from cwebber.
http://bugs.foocorp.net/issues/489#note-2
This commit is contained in:
parent
47364ead6b
commit
d71170ad0a
@ -20,7 +20,7 @@ direct_remote_path = string(default="/mgoblin_static/")
|
||||
# set to false to enable sending notices
|
||||
email_debug_mode = boolean(default=True)
|
||||
email_sender_address = string(default="notice@mediagoblin.example.org")
|
||||
email_smtp_host = string(default=None)
|
||||
email_smtp_host = string(default='')
|
||||
email_smtp_port = integer(default=25)
|
||||
email_smtp_user = string(default=None)
|
||||
email_smtp_pass = string(default=None)
|
||||
|
@ -237,10 +237,7 @@ class FakeMhost(object):
|
||||
Just a fake mail host so we can capture and test messages
|
||||
from send_email
|
||||
"""
|
||||
def connect(self):
|
||||
pass
|
||||
|
||||
def login(self):
|
||||
def login(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def sendmail(self, from_addr, to_addrs, message):
|
||||
@ -273,14 +270,16 @@ def send_email(from_addr, to_addrs, subject, message_body):
|
||||
if TESTS_ENABLED or mg_globals.app_config['email_debug_mode']:
|
||||
mhost = FakeMhost()
|
||||
elif not mg_globals.app_config['email_debug_mode']:
|
||||
if not mg_globals.app_config['email_smtp_host']:
|
||||
mhost = smtplib.SMTP()
|
||||
else:
|
||||
mhost = smtplib.SMTP(
|
||||
mg_globals.app_config['email_smtp_host'],
|
||||
mg_globals.app_config['email_smtp_port'])
|
||||
|
||||
if mg_globals.app_config['email_smtp_user']:
|
||||
# SMTP.__init__ Issues SMTP.connect implicitly if host
|
||||
if not mg_globals.app_config['email_smtp_host']: # e.g. host = ''
|
||||
mhost.connect() # We SMTP.connect explicitly
|
||||
|
||||
if mg_globals.app_config['email_smtp_user'] \
|
||||
or mg_globals.app_config['email_smtp_pass']:
|
||||
mhost.login(
|
||||
mg_globals.app_config['email_smtp_user'],
|
||||
mg_globals.app_config['email_smtp_pass'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user