July 26, 2020

SOLVE - SMTP Open edX Timeout

By default in Open edX, the system will send an email when a new user registers, using the forget password or other conditions.

A few days ago my teams found an issue on the email sending service, but the issue was not because of the Open edX SMTP service but from the connection side of the Open edX server to the SMTP server.

Then what’s the case?

Case:

-) When a user registers, the user should receive an email to activate the account, but in reality it is not. When checking the log file, log is found as follows:

Jul 10 16:50:32 e-Learning [service_variant=lms][edx.celery.task][env:sandbox] ERROR [e-Learning  7227] [tasks.py:48] - Unable to send activation email to user from "[email protected]" to "[email protected]"
Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/common/djangoapps/student/tasks.py", line 23, in send_activation_email
    mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail
    return mail.send()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/mail/message.py", line 348, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 111, in send_messages
    sent = self._send(message)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 127, in _send
    self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
  File "/usr/lib/python2.7/smtplib.py", line 751, in sendmail
    raise SMTPDataError(code, resp)
SMTPDataError: (554, 'Message rejected: Email address is not verified. The following identities failed the check in region US-EAST-1: [email protected]')

Is it possible due to a misconfiguration of the SMTP account on the Open edX server?

-) If the user has not activated the account, at the second login the activation email will be sent again. In this step, the new user gets an activation email.

-) When the user uses the password forgetting feature, the forgotten password email also enters.

This means that it should not be due to a misconfiguration of the SMTP account on the Open edX server, the email was successfully entered in a case other than activation email. But at that time you had to wait for the email to arrive. So there is a possibility because of the timeout.

This friend of mine seems to be a fad to set up an email timeout, in the file /edx/app/edxapp/lms.env.json added "EMAIL_TIMEOUT": timeout. In this case our email timeout is set to 300 seconds so it’s more config like this:

    "EMAIL_HOST": "mail.sibunglon.com",
    "EMAIL_PORT": 587,
    "EMAIL_USE_TLS": true,
    "EMAIL_TIMEOUT": 300,

Also add the config to /edx/app/edxapp/cms.env.json, then restart lms and cms.

After the EMAIL_TIMEOUT config is added, our issue can change the status to Solved.😁🥳

Thanks you Ady Rahmat MA for solve this issue.