Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plain redirect subjects #3209

Merged
merged 3 commits into from
Feb 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions esp/mailgates/mailgate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Main mailgate for ESP.
# Main mailgate
# Handles incoming messages etc.

import sys, os, email, re, smtplib, socket, sha, random
Expand All @@ -10,13 +10,13 @@
os.environ['DJANGO_SETTINGS_MODULE'] = 'esp.settings'

import logging
# Make sure we end up in our logger even though this file is outside esp
# Make sure we end up in our logger even though this file is outside esp/esp/
logger = logging.getLogger('esp.mailgate')

import os.path
project = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

# Path for ESP code
# Path for site code
sys.path.insert(0, project)

# Check if a virtualenv has been installed and activated from elsewhere.
Expand All @@ -39,12 +39,11 @@
server = smtplib.SMTP('localhost')
ARCHIVE = settings.DEFAULT_EMAIL_ADDRESSES['archive']
SUPPORT = settings.DEFAULT_EMAIL_ADDRESSES['support']
ORGANIZATION_NAME = settings.INSTITUTION_NAME + '_' + settings.ORGANIZATION_SHORT_NAME

DEBUG=True
#DEBUG=True
DEBUG=False

#os.environ['LOCAL_PART'] = 'axiak'

user = "UNKNOWN USER"

def send_mail(message):
Expand Down Expand Up @@ -89,7 +88,7 @@ def send_mail(message):

subject = message['subject']
del(message['subject'])
if instance.emailcode:
if hasattr(instance, 'emailcode') and instance.emailcode:
subject = '[%s] %s' % (instance.emailcode, subject)
if handler.subject_prefix:
subject = '[%s] %s' % (handler.subject_prefix, subject)
Expand Down Expand Up @@ -129,15 +128,12 @@ def send_mail(message):
else:
logger.warning("Couldn't find user '%s'", user)
print """
ESP MAIL SERVER
%s MAIL SERVER
===============

Could not find user "%s"

If you are experiencing difficulty, please email %s.

-Educational Studies Program


""" % (user, SUPPORT)
""" % (ORGANIZATION_NAME, user, SUPPORT)
sys.exit(1)