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_HOST_PASSWORD = "my_password"
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:

    '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 but it doesn’t change anything.

I tried to change SMTP port to 465 like described here:, but same thing, no change.

Does somebady have an idea?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

For this type of use I would strongly recommend using a transactional mail service like SendGrid rather than gmail. It provides a more robust option and many providers like this have a free tier and pre-written modules/classes/libraries for numerous languages that you can include.

You should be able to disable the fail_silently option on your send function in order to get it to provide you information on why the request is failing or at least how the remote SMTP server is responding.