publicstore_base_url = /mgoblin_media/
direct_remote_path = /mgoblin_static/
email_sender_address = "notice@mediagoblin.example.org"
+# set to false to enable sending notices
+email_debug_mode = true
## Uncomment this to put some user-overriding templates here
#local_templates = %(here)s/user_dev/templates/
import routes
import mongokit
+from paste.deploy.converters import asbool
from webob import Request, exc
from mediagoblin import routing, util, models, storage, staticdirect
def __init__(self, connection, database_path,
public_store, queue_store,
staticdirector,
- email_sender_address,
+ email_sender_address, email_debug_mode,
user_template_path=None):
# Get the template environment
self.template_env = util.get_jinja_env(user_template_path)
# object.
setup_globals(
email_sender_address=email_sender_address,
+ email_debug_mode=email_debug_mode,
db_connection=connection,
database=self.db,
public_store=self.public_store,
connection, app_config.get('db_name', 'mediagoblin'),
public_store=public_store, queue_store=queue_store,
staticdirector=staticdirector,
- email_sender_address=app_config.get('email_sender_address',
- 'notice@mediagoblin.example.org'),
+ email_sender_address=app_config.get(
+ 'email_sender_address', 'notice@mediagoblin.example.org'),
+ email_debug_mode=app_config.get('email_debug_mode'),
user_template_path=app_config.get('local_templates'))
return mgoblin_app
import jinja2
import mongokit
+from mediagoblin import globals as mgoblin_globals
+
TESTS_ENABLED = False
def _activate_testing():
- message_body: email body text
"""
# TODO: make a mock mhost if testing is enabled
- if TESTS_ENABLED:
+ if TESTS_ENABLED or mgoblin_globals.email_debug_mode:
mhost = FakeMhost()
- else:
+ elif not mgoblin_globals.email_debug_mode:
mhost = smtplib.SMTP()
mhost.connect()
if TESTS_ENABLED:
EMAIL_TEST_INBOX.append(message)
- return mhost.sendmail(from_addr, to_addrs, message.as_string())
+ elif mgoblin_globals.email_debug_mode:
+ print u"===== Email ====="
+ print u"From address: %s" % message['From']
+ print u"To addresses: %s" % message['To']
+ print u"Subject: %s" % message['Subject']
+ print u"-- Body: --"
+ print message.get_payload(decode=True)
+
+ else:
+ return mhost.sendmail(from_addr, to_addrs, message.as_string())