Skip to content

Commit a363016

Browse files
feat: route account activation emails via SES using waffle flag
1 parent e0b2d6b commit a363016

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

common/djangoapps/student/views/management.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
from common.djangoapps.util.json_request import JsonResponse
9090
from common.djangoapps.student.signals import USER_EMAIL_CHANGED
9191
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
92+
from edx_toggles.toggles import WaffleFlag
9293

9394
log = logging.getLogger("edx.student")
9495

@@ -110,6 +111,19 @@
110111
REGISTRATION_UTM_CREATED_AT = 'registration_utm_created_at'
111112
USER_ACCOUNT_ACTIVATED = 'edx.user.account.activated'
112113

114+
# .. toggle_name: user_authn.enable_ses_for_account_activation
115+
# .. toggle_implementation: WaffleFlag
116+
# .. toggle_default: False
117+
# .. toggle_description: Route account activation emails via SES using ACE.
118+
# .. toggle_use_cases: opt_in, temporary
119+
# .. toggle_creation_date: 2026-01-22
120+
# .. toggle_target_removal_date: None
121+
# .. toggle_warning: This toggle controls email delivery routing and should be enabled cautiously.
122+
ENABLE_SES_FOR_ACCOUNT_ACTIVATION = WaffleFlag(
123+
'user_authn.enable_ses_for_account_activation',
124+
__name__,
125+
)
126+
113127

114128
def csrf_token(context):
115129
"""
@@ -229,6 +243,21 @@ def compose_activation_email(
229243
language=preferences_api.get_user_preference(user, LANGUAGE_KEY),
230244
user_context=message_context,
231245
)
246+
if ENABLE_SES_FOR_ACCOUNT_ACTIVATION.is_enabled():
247+
log.info(
248+
"ACCOUNT ACTIVATION EMAIL | SES flag=%s | override_channel=%s",
249+
ENABLE_SES_FOR_ACCOUNT_ACTIVATION.is_enabled(),
250+
msg.options.get('override_default_channel')
251+
)
252+
msg.options.update({
253+
'transactional': True,
254+
'override_default_channel': 'django_email',
255+
'from_address': configuration_helpers.get_value(
256+
'ACTIVATION_EMAIL_FROM_ADDRESS'
257+
) or configuration_helpers.get_value(
258+
'email_from_address', settings.DEFAULT_FROM_EMAIL
259+
),
260+
})
232261

233262
return msg
234263

0 commit comments

Comments
 (0)