I am trying to send an email from my django application.
However, this does not work on my NGINX (used for static resources) + GUNICORN Server.
But, the same works on django's default webserver. I have not setup a mail server per se as of now.
I am not sure what the problem is.
Let me explain the entire situation as the question was ill explained.
If I send an email from my web app which is in Django using the default debugging WSGI,
and the following code
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', 'from@example.com',
['to@example.com'], fail_silently=False)
I am able to send the email.
However, I have setup an nginx server and a gunicorn wsgi together. I am not able to send mails.
My nginx.conf looks like this
server {
listen 80;
listen 443;
listen 587;
server_name 172.17.110.205;
client_max_body_size 0M;
access_log /home/msrb_db/msrb_db_application/access.log;
error_log /home/msrb_db/msrb_db_application/error.log;
location /static {
root /home/msrb_db/msrb_db_application;
}
location / {
proxy_pass http://172.17.110.205:8080;
}
}
And I have a gunicorn server as a systemd file which works as follows
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=msrb_db
Group=users
WorkingDirectory=/home/msrb_db/msrb_db_application/
ExecStart=/usr/bin/gunicorn --bind 172.17.110.205:8080 --workers 3 --pythonpath /home/msrb_db/msrb_db_application/ msrb_db_application.wsgi:application
[Install]
WantedBy=multi-user.target
~
I have also tried this using the other api for gmail using the EmailMessageClass
My settings.py are as follows
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 443
EMAIL_HOST_USER = 'abc@abc.com
EMAIL_HOST_PASSWORD = 'plplplp'
~
I am not sure what I am missing over here. Any help is appreciated.
Django Logs:
Hi, so I took out the logs from Django and I found no exception related to Email
/post/test_csv.zip' already exists
Nov 19 10:06:10 msrbdb gunicorn[58290]: sending email
Nov 19 10:06:10 msrbdb gunicorn[58290]: email sent
Nov 19 10:06:10 msrbdb gunicorn[58290]: Exception SystemExit: 0 in <module 'threading' from '/usr/lib64/python2.7/threading.pyc'> ignored
And, NGINX has no errors
Thanks a lot.