# 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_port = integer(default=25)
+email_smtp_user = string(default=None)
+email_smtp_pass = string(default=None)
# Set to false to disable registrations
allow_registration = boolean(default=True)
def connect(self):
pass
+ def login(self):
+ pass
+
def sendmail(self, from_addr, to_addrs, message):
EMAIL_TEST_MBOX_INBOX.append(
{'from': from_addr,
- subject: subject of the email
- message_body: email body text
"""
- # TODO: make a mock mhost if testing is enabled
if TESTS_ENABLED or mg_globals.app_config['email_debug_mode']:
mhost = FakeMhost()
elif not mg_globals.app_config['email_debug_mode']:
- mhost = smtplib.SMTP()
-
- mhost.connect()
+ 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']:
+ mhost.login(
+ mg_globals.app_config['email_smtp_user'],
+ mg_globals.app_config['email_smtp_pass'])
message = MIMEText(message_body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject