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,21 +1791,32 @@ def create_account_with_params(request, params): ...@@ -1791,21 +1791,32 @@ def create_account_with_params(request, params):
'email_from_address', 'email_from_address',
settings.DEFAULT_FROM_EMAIL settings.DEFAULT_FROM_EMAIL
) )
try: retries = settings.RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS
if settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL'): while retries:
dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL'] try:
message = ("Activation for %s (%s): %s\n" % (user, user.email, profile.name) + if settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL'):
'-' * 80 + '\n\n' + message) dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL']
mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False) message = ("Activation for %s (%s): %s\n" % (user, user.email, profile.name) +
else: '-' * 80 + '\n\n' + message)
user.email_user(subject, message, from_address) mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False)
except Exception: # pylint: disable=broad-except else:
log.error( user.email_user(subject, message, from_address)
u'Unable to send activation email to user from "%s" to "%s"', # Log that the Activation Email has been sent to user without an exception
from_address, log.info("Activataion Email has been sent to User {user_email}".format(
dest_addr, user_email=dest_addr
exc_info=True ))
) break
except Exception: # pylint: disable=broad-except
retries -= 1
if retries <= 0:
break
log.error(
u'Unable to send activation email to user from "%s" to "%s"',
from_address,
dest_addr,
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