Commit 4bbeaf32 by attiyaishaque

ECOM-5281 Add retires for email sending while registering.

parent 45e243da
...@@ -335,3 +335,6 @@ INSTALLED_APPS += ('openedx.core.djangoapps.api_admin',) ...@@ -335,3 +335,6 @@ INSTALLED_APPS += ('openedx.core.djangoapps.api_admin',)
# Set the default Oauth2 Provider Model so that migrations can run in # Set the default Oauth2 Provider Model so that migrations can run in
# verbose mode # verbose mode
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application' OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'
# Used with Email sending
RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS = 5
...@@ -1791,6 +1791,8 @@ def create_account_with_params(request, params): ...@@ -1791,6 +1791,8 @@ def create_account_with_params(request, params):
'email_from_address', 'email_from_address',
settings.DEFAULT_FROM_EMAIL settings.DEFAULT_FROM_EMAIL
) )
retries = settings.RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS
while retries:
try: try:
if settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL'): if settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL'):
dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL'] dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL']
...@@ -1799,13 +1801,22 @@ def create_account_with_params(request, params): ...@@ -1799,13 +1801,22 @@ def create_account_with_params(request, params):
mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False) mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False)
else: else:
user.email_user(subject, message, from_address) user.email_user(subject, message, from_address)
# Log that the Activation Email has been sent to user without an exception
log.info("Activataion Email has been sent to User {user_email}".format(
user_email=dest_addr
))
break
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
retries -= 1
if retries <= 0:
break
log.error( log.error(
u'Unable to send activation email to user from "%s" to "%s"', u'Unable to send activation email to user from "%s" to "%s"',
from_address, from_address,
dest_addr, dest_addr,
exc_info=True exc_info=True
) )
else: else:
registration.activate() registration.activate()
_enroll_user_in_pending_courses(user) # Enroll student in any pending courses _enroll_user_in_pending_courses(user) # Enroll student in any pending courses
......
...@@ -370,6 +370,9 @@ GENERATE_PROFILE_SCORES = False ...@@ -370,6 +370,9 @@ GENERATE_PROFILE_SCORES = False
# Used with XQueue # Used with XQueue
XQUEUE_WAITTIME_BETWEEN_REQUESTS = 5 # seconds XQUEUE_WAITTIME_BETWEEN_REQUESTS = 5 # seconds
# Used with Email sending
RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS = 5
############################# SET PATH INFORMATION ############################# ############################# SET PATH INFORMATION #############################
PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /edx-platform/lms PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /edx-platform/lms
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment