Monday, March 21, 2016

edx-platform - How to make SMTP work on your Open EdX instance the proper way

There were several threads in the Open EdX mailing list asking about how to make the email working. But, it seams like there is no proper instructions out there to help people. So, I decided to write something about that.

Firstly, there are 3 simple things to keep in mind:
  • All the authentication information should be kept privately.
  • If you add them to the edx-platform source files there will be conflicts when you upgrade or pull from master/branches.
  • So, the best place to keep all the settings for all your Open edX applications is /edx/app/edx_ansible/server-vars.yml

0. Checkout all of your modification on: (to avoid source code conflicts)

cms/envs/common.py
lms/envs/aws.py
cms.env.json
cms.auth.json
lms.env.json
lms.auth.json


1. Create server-vars.yml in /edx/app/edx_ansible/
2. Add these following variables to server-vars.yml with your SMTP information:

EDXAPP_EMAIL_BACKEND: 'django.core.mail.backends.smtp.EmailBackend'
EDXAPP_EMAIL_HOST: 'localhost'
EDXAPP_EMAIL_PORT: 25
EDXAPP_EMAIL_USE_TLS: False
EDXAPP_EMAIL_HOST_USER: ''
EDXAPP_EMAIL_HOST_PASSWORD: ''

...
# you can add more here

Notes:
  • These settings use the local smtp service to sent out messages. If you want to use gmail or your own smtp server, change them.
  • For more vars, please read this.
3. Run the update command to apply the changes:


sudo /edx/bin/update edx-platform master

You can add this line in /edx/app/edx_ansible/server-vars.yml to pull code from your folked edx-platform:

edx_platform_repo: "https://github.com/<user>/edx-platform.git"

For more instructions, read here.

4. By default, the LMS runs on port 18000, if after the provisioning it changes back to that port, go to /etc/nginx/sites-available/lms and modify the server port (80). Then restart nginx.

5. Compile the assets:

sudo -H -u edxapp bash
source /edx/app/edxapp/edxapp_env
cd /edx/app/edxapp/edx-platform
paver update_assets cms --settings=aws
paver update_assets lms --settings=aws