Question
Django + gmail + nginx + allauth: unable to send email (but works on localhost)
I’m working on a Django application with a registration by email with confirmation (using allauth).
When the user create a new account, he receive a confirmation email on his email box.
All works perfect on my local machine.
But when I try it on my digital ocean server (Ubuntu 16.04), the email is not sent.
My Django email settings are:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = "my_email@gmail.com"
EMAIL_HOST_PASSWORD = "my_password"
EMAIL_PORT = 587
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
My error.log file is empty, it seems like there is no error from the Python server, or maybe my logfile is not correctly configured:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'ERROR',
'class': 'logging.FileHandler',
'filename': './error.log',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'ERROR',
'propagate': True,
},
},
}
I tried to allow access to my Google account using external application with this link https://accounts.google.com/b/0/DisplayUnlockCaptcha but it doesn’t change anything.
I tried to change SMTP port to 465 like described here: https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server, but same thing, no change.
Does somebady have an idea?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×