Error sending email from django app
I’ve started a new production droplet in NYC2, it has virt-io, and backup.
I have a django application with many other services running, like redis, node, sockjs and celery.
Also, i want to point ou that my local server runs the exact same configuration with regards to email, and everything works fine.
I did not change anything regarding to firewall or networking in my droplet.
Can anybody help me fix this error?
My problem is that i can’t send email from my django app.
My configuration is :
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 #also tried with 465 EMAIL_HOST_USER = 'firstname.lastname@example.org' EMAIL_HOST_PASSWORD = 'MyPassWOrd'
Here is the error:
File "<console>", line 1, in <module> File "......./models.py", line 158, in email_user send_mail(subject, message, from_email, [self.email]) File "......./local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 50, in send_mail connection=connection).send() File "........./local/lib/python2.7/site-packages/django/core/mail/message.py", line 274, in send return self.get_connection(fail_silently).send_messages([self]) File "........./local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 87, in send_messages new_conn_created = self.open() File "........./local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 48, in open local_hostname=DNS_NAME.get_fqdn()) File "/usr/lib/python2.7/smtplib.py", line 251, in __init__ (code, msg) = self.connect(host, port) File "/usr/lib/python2.7/smtplib.py", line 311, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python2.7/smtplib.py", line 286, in _get_socket return socket.create_connection((host, port), timeout) File "/usr/lib/python2.7/socket.py", line 571, in create_connection raise err error: [Errno 101] Network is unreachable
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.×