# set to false to enable sending notices
email_debug_mode = boolean(default=True)
email_smtp_use_ssl = boolean(default=False)
+email_smtp_force_tls = boolean(default=False)
email_sender_address = string(default="notice@mediagoblin.example.org")
email_smtp_host = string(default='')
email_smtp_port = integer(default=0)
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import six
import smtplib
+import sys
from email.MIMEText import MIMEText
from mediagoblin import mg_globals, messages
from mediagoblin.tools import common
'to': to_addrs,
'message': message})
+ def starttls(self):
+ raise smtplib.SMTPException("No STARTTLS here")
def _clear_test_inboxes():
global EMAIL_TEST_INBOX
if not mg_globals.app_config['email_smtp_host']: # e.g. host = ''
mhost.connect() # We SMTP.connect explicitly
+ try:
+ mhost.starttls()
+ except smtplib.SMTPException:
+ # Only raise an exception if we're forced to
+ if mg_globals.app_config['email_smtp_force_tls']:
+ six.reraise(*sys.exc_info())
+
if ((not common.TESTS_ENABLED)
and (mg_globals.app_config['email_smtp_user']
or mg_globals.app_config['email_smtp_pass'])):