Answer the question
In order to leave comments, you need to log in
How to set up smtp mail in Django?
I want to set up sending emails through external smtp services. The application is installed on uwsgi and nginx, ssl certificates are connected with a permanent redirect to https. I restart uwsgi, nginx every time (and even through -s reload). I tried several smtp services - the result is zero. Changed ports. Tried send_mail via shell - it just doesn't output anything. I alternated between different parameters - but none of them sent letters, even on a LAN via gmail - everything was ok. The last 2 I tried are SendGrid and SendinBlue. In settings specified backend. It feels like I'm missing some important setting.
Here is settings.py:
EMAIL_HOST = 'smtp-relay.sendinblue.com'
EMAIL_HOST_USER = 'login' # типо адекватный логин
EMAIL_HOST_PASSWORD = 'password' # типо адекватный пароль
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = DEFAULT_FROM_EMAIL = 'apikey'
EMAIL_HOST_PASSWORD = 'big api key'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_SSL_CERTFILE = os.path.join(BASE_DIR, "certs", "certificate.crt")
EMAIL_SSL_KEYFILE = os.path.join(BASE_DIR, "certs", "private.key")
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
Answer the question
In order to leave comments, you need to log in
The reason is closed outgoing ports. But I even put a postfix, thinking that it was my mistake)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question