diff --git a/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py b/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py index 0f8227e3201a..5b4d84d8f2c1 100644 --- a/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py +++ b/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py @@ -23,7 +23,7 @@ from openedx.core.djangoapps.user_api.preferences.api import get_user_preference from openedx.core.lib.celery.task_utils import emulate_http_request from openedx.features.course_duration_limits.access import get_user_course_expiration_date -from openedx.features.course_experience import ENABLE_COURSE_GOALS +from openedx.features.course_experience import ENABLE_COURSE_GOALS, ENABLE_SES_FOR_GOALREMINDER from openedx.features.course_experience.url_helpers import get_learning_mfe_home_url log = logging.getLogger(__name__) @@ -86,13 +86,24 @@ def send_ace_message(goal): 'programs_url': getattr(settings, 'ACE_EMAIL_PROGRAMS_URL', None), }) + options = {'transactional': True} + + is_ses_enabled = ENABLE_SES_FOR_GOALREMINDER.is_enabled(goal.course_key) + + if is_ses_enabled: + options = { + 'transactional': True, + 'from_address': settings.LMS_COMM_DEFAULT_FROM_EMAIL, + 'override_default_channel': is_ses_enabled, + } + msg = Message( name="goalreminder", app_label="course_goals", recipient=Recipient(user.id, user.email), language=language, context=message_context, - options={'transactional': True}, + options=options, ) with emulate_http_request(site, user): diff --git a/lms/envs/common.py b/lms/envs/common.py index df8878f26914..60f6515d510d 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -5541,3 +5541,6 @@ def _should_send_learning_badge_events(settings): # .. for now it wil impact country listing in auth flow and user profile. # .. eg ['US', 'CA'] DISABLED_COUNTRIES = [] + + +LMS_COMM_DEFAULT_FROM_EMAIL = "no-reply@example.com" diff --git a/openedx/features/course_experience/__init__.py b/openedx/features/course_experience/__init__.py index f8a662709ee7..a45d863e09c5 100644 --- a/openedx/features/course_experience/__init__.py +++ b/openedx/features/course_experience/__init__.py @@ -34,6 +34,16 @@ # .. toggle_warning: This temporary feature toggle does not have a target removal date. ENABLE_COURSE_GOALS = CourseWaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.enable_course_goals', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation +# .. toggle_name: course_experience.enable_ses_for_goalreminder +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: Used to determine whether or not to use AWS SES to send goal reminder emails for the course. +# .. toggle_use_cases: opt_in, temporary +# .. toggle_creation_date: 2024-10-06 +# .. toggle_target_removal_date: None +# .. toggle_warning: This temporary feature toggle does not have a target removal date. +ENABLE_SES_FOR_GOALREMINDER = CourseWaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.enable_ses_for_goalreminder', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation + # Waffle flag to enable anonymous access to a course SEO_WAFFLE_FLAG_NAMESPACE = 'seo' COURSE_ENABLE_UNENROLLED_ACCESS_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation