diff --git a/zerver/context_processors.py b/zerver/context_processors.py index 8c4170efd4..644afa40e3 100644 --- a/zerver/context_processors.py +++ b/zerver/context_processors.py @@ -15,6 +15,7 @@ from zproject.backends import ( AUTH_BACKEND_NAME_MAP ) from zerver.lib.bugdown import convert +from zerver.lib.send_email import FromAddress from zerver.lib.utils import get_subdomain from zerver.lib.realm_icon import get_realm_icon_url @@ -111,7 +112,7 @@ def zulip_default_context(request): 'any_oauth_backend_enabled': any_oauth_backend_enabled(realm), 'no_auth_enabled': not auth_enabled_helper(list(AUTH_BACKEND_NAME_MAP.keys()), realm), 'development_environment': settings.DEVELOPMENT, - 'support_email': settings.ZULIP_ADMINISTRATOR, + 'support_email': FromAddress.SUPPORT, 'find_team_link_disabled': find_team_link_disabled, 'password_min_length': settings.PASSWORD_MIN_LENGTH, 'password_min_quality': settings.PASSWORD_MIN_ZXCVBN_QUALITY, diff --git a/zerver/forms.py b/zerver/forms.py index 0da9786115..2652502c39 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -14,7 +14,7 @@ from jinja2 import Markup as mark_safe from zerver.lib.actions import do_change_password, is_inactive, user_email_is_unique from zerver.lib.name_restrictions import is_reserved_subdomain, is_disposable_domain from zerver.lib.request import JsonableError -from zerver.lib.send_email import send_email +from zerver.lib.send_email import send_email, FromAddress from zerver.lib.users import check_full_name from zerver.lib.utils import get_subdomain, check_subdomain from zerver.models import Realm, get_user_profile_by_email, UserProfile, \ @@ -34,7 +34,7 @@ MIT_VALIDATION_ERROR = u'That user does not exist at MIT or is a ' + \ u'contact us.' WRONG_SUBDOMAIN_ERROR = "Your Zulip account is not a member of the " + \ "organization associated with this subdomain. " + \ - "Please contact %s with any questions!" % (settings.ZULIP_ADMINISTRATOR,) + "Please contact %s with any questions!" % (FromAddress.SUPPORT,) def email_is_not_mit_mailing_list(email): # type: (Text) -> None @@ -253,13 +253,13 @@ class OurAuthenticationForm(AuthenticationForm): Please contact %s to reactivate this group.""" % ( user_profile.realm.name, - settings.ZULIP_ADMINISTRATOR) + FromAddress.SUPPORT) raise ValidationError(mark_safe(error_msg)) if not user_profile.is_active: error_msg = (u"Sorry for the trouble, but your account has been " u"deactivated. Please contact %s to reactivate " - u"it.") % (settings.ZULIP_ADMINISTRATOR,) + u"it.") % (FromAddress.SUPPORT,) raise ValidationError(mark_safe(error_msg)) if not check_subdomain(get_subdomain(self.request), user_profile.realm.subdomain): diff --git a/zerver/lib/feedback.py b/zerver/lib/feedback.py index a891c8db89..bf93e86c7a 100644 --- a/zerver/lib/feedback.py +++ b/zerver/lib/feedback.py @@ -5,6 +5,7 @@ from django.core.mail import EmailMessage from typing import Any, Mapping, Optional, Text from zerver.lib.actions import internal_send_message +from zerver.lib.send_email import FromAddress from zerver.lib.redis_utils import get_redis_client from zerver.models import get_realm, get_system_bot, \ UserProfile, Realm @@ -75,7 +76,7 @@ def handle_feedback(event): to_email = settings.FEEDBACK_EMAIL subject = "Zulip feedback from %s" % (event["sender_email"],) content = event["content"] - from_email = '"%s" <%s>' % (event["sender_full_name"], settings.ZULIP_ADMINISTRATOR) + from_email = '"%s" <%s>' % (event["sender_full_name"], FromAddress.SUPPORT) headers = {'Reply-To': '"%s" <%s>' % (event["sender_full_name"], event["sender_email"])} msg = EmailMessage(subject, content, from_email, [to_email], headers=headers) msg.send() diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py index da6846c3ed..bcdd88a9f4 100644 --- a/zerver/lib/send_email.py +++ b/zerver/lib/send_email.py @@ -25,7 +25,7 @@ def build_email(template_prefix, to_email, from_name=None, from_address=None, reply_to_email=None, context={}): # type: (str, Text, Optional[Text], Optional[Text], Optional[Text], Dict[str, Any]) -> EmailMultiAlternatives context.update({ - 'support_email': settings.ZULIP_ADMINISTRATOR, + 'support_email': FromAddress.SUPPORT, 'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS, }) subject = loader.render_to_string(template_prefix + '.subject', diff --git a/zerver/management/commands/send_test_email.py b/zerver/management/commands/send_test_email.py index eccd2f4af5..8017a69ae5 100644 --- a/zerver/management/commands/send_test_email.py +++ b/zerver/management/commands/send_test_email.py @@ -6,6 +6,8 @@ from django.conf import settings from django.core.mail import mail_admins, mail_managers, send_mail from django.core.management.commands import sendtestemail +from zerver.lib.send_email import FromAddress + class Command(sendtestemail.Command): def handle(self, *args, **kwargs): # type: (*Any, **str) -> None @@ -13,7 +15,7 @@ class Command(sendtestemail.Command): message = ("Success! If you receive this message, you've " "successfully configured sending email from your " "Zulip server.") - sender = settings.ZULIP_ADMINISTRATOR + sender = FromAddress.SUPPORT send_mail(subject, message, sender, kwargs['email']) if kwargs['managers']: