|
89 | 89 | from common.djangoapps.util.json_request import JsonResponse |
90 | 90 | from common.djangoapps.student.signals import USER_EMAIL_CHANGED |
91 | 91 | from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order |
| 92 | +from edx_toggles.toggles import WaffleFlag |
92 | 93 |
|
93 | 94 | log = logging.getLogger("edx.student") |
94 | 95 |
|
|
110 | 111 | REGISTRATION_UTM_CREATED_AT = 'registration_utm_created_at' |
111 | 112 | USER_ACCOUNT_ACTIVATED = 'edx.user.account.activated' |
112 | 113 |
|
| 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 | + |
113 | 127 |
|
114 | 128 | def csrf_token(context): |
115 | 129 | """ |
@@ -229,6 +243,21 @@ def compose_activation_email( |
229 | 243 | language=preferences_api.get_user_preference(user, LANGUAGE_KEY), |
230 | 244 | user_context=message_context, |
231 | 245 | ) |
| 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 | + }) |
232 | 261 |
|
233 | 262 | return msg |
234 | 263 |
|
|
0 commit comments