The native build of Open edX relies on a simple email generator utility that comes with Ubuntu 16.04. While this technically works, the messages that it generates for new user activations, password reset instructions, and welcome messages are generally universally flagged as spam by common email management client applications like MS Outlook, Mac Mail and so on. Fortunately however, the architects of Open edX have made it easy for you to integrate an SMTP email account to your instance. Take note that the configuration procedure has been simplified over time, but much of the online documentation that I find has not kept pace with these changes, and this can make it appear as though getting SMTP email working is more complicated that it really is.
We’ll integrate a Google Gmail account in this tutorial, but you can use just about any other SMTP mail provider and these instructions will still be valid. Google’s Gmail email service is designed to be accessed by third party applications. The email management software that you use on your Desktop and mobile devices for example are third-party apps that provide the means to quickly connect and synchronize your local email message storage system to Gmail’s email services.
SMTP is a standardized protocol that Gmail and many other email providers use to allow third party applications to integrate and synchronize with the central email servers of the service provider. Apple and Android both provide really good out-of-the-box mobile apps for email that let you connect to a Gmail account; usually requiring no more than a user name and password. Open edX uses the same approach, but without the nice GUI interface.
1. Configure Your Gmail Account
There is one small but important change that you’ll need to make to your default Gmail account settings in order for Gmail to allow Open edX to connect. After logging in to your Gmail account from a web browser, navigate to https://myaccount.google.com/lesssecureapps to change the setting for “Allow less secure apps” to “On”.
2. Edit /edx/app/edxapp/lms.auth.json
lms.auth.json contains authorization credentials for the various subsystems that support the Learning Management System (LMS) application; email username and password being two such credentials. Each time the LMS attempts to send an email message it refers to the username and password from this file to establish a connection and send the message using the Gmail SMTP email service.
Pro Tip: Keep a backup copy of the original versions of each of the four JSON files in /edx/app/edxapp. JSON syntax is as rigid as it is unforgiving, and any syntax errors in these four JSON files will prevent your Open edX platform from restarting.
3. Edit /edx/app/edxapp/cms.auth.json
cms.auth.json contains authorization credentials for the various subsystems that support the Course Management Studio (CMS) application. The structure of this file is similar, but not identical to that of lms.auth.json from the previous step. You’ll also add your Gmail username and password to this file.
4. Edit /edx/app/edxapp/lms.env.json
lms.env.json contains application parameters and option values for the LMS. You’ll do two things in this file. First, you’ll add your Google Gmail SMTP settings, and second, you’ll set your gmail email address in various locations in the file.
Note that you’ll find other parameters in this file with an “EMAIL_” prefix. If I don’t mention them in this article then they’re not required for setting up SMTP email.
|EMAIL_BACKEND||The default value might look similar, so check this carefully to ensure that you’re instructing Django to use SMTP rather than the default Ubuntu email generator utility.|
|EMAIL_HOST||This is the fully qualified domain name for the email service that you’re using (Google Gmail in the case of this tutorial). If you’re using a different mail provider then you should ensure that you provide a Fully Qualified Domain Name (FQDM) here.|
|EMAIL_PORT||The port assignment is specific to the service provider that you’re using, and it’s arbitrary, so don’t try to guess.|
|EMAIL_USE_TLS||This value is specific to your provider. This is a true/false flag indicating whether email connections will be established using secure HTTPS protocol with TLS (a new improved alternative to SSL).|
Note: If you’re using Ginkgo then you can disregard this step. Next you will potentially update several email addresses, depending on the version you are running. Until Ginkgo, the Open edX platform recognized nearly a dozen different email addresses for roles ranging from new user activation to bug reports. If you’re using a version other than Ginkgo then you’ll need to do a search-replace on “@example.com” to correctly set these values.
5. Edit /edx/app/edxapp/cms.env.json
This file is virtually identical in both layout and substance to lms.env.json. You should duplicate all edits that you made in the previous step.
6. Restart Open edX
You’ll need to restart the Open edX platform in order for these changes to take effect. Keep in mind that restarting the platform takes around 10 minutes and that it will be unavailable to learners and instructors during this time. Also keep in mind that any syntax errors you might have made while editing the JSON files will prevent the Open edX platform from starting.
# For Ginkgo and newer
/edx/bin/supervisorctl restart lms
/edx/bin/supervisorctl restart cms
/edx/bin/supervisorctl restart edxapp_worker:
For older versions of Open edX (prior to Ginkgo) you should use this alternative syntax. Note that The “:” character is part of each of these two commands.
/edx/bin/supervisorctl restart edxapp:
/edx/bin/supervisorctl restart edxapp_worker:
7. Test Your Work
You can easily verify your results by requesting a password reset email using the “Forgot Password?” from your Open edX login screen. This simple utility will attempt to use your new SMTP email settings to generate the password reset email using Google Gmail. If it works then you’ll not only instantly receive the email but you’ll also be able to see a copy of the message in the “Sent Mail” for your Gmail account.
I hope you found this helpful. Please help me improve this article by leaving a comment below. Thank you!