I am trying to send an email via my company's smtp server. Here are my settings:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'blah'
EMAIL_HOST_USER = 'blah'
EMAIL_HOST_PASSWORD = 'blah'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
Here is the error message I got:
[22/Jun/2016 17:31:20] ERROR [uer_application.views:68] Traceback (most recent call last):
Traceback (most recent call last):
File "/Users/cheng/Dev/diandi/uer_application/views.py", line 65, in send_email
File "/Users/cheng/Dev/diandi/uer_application/views.py", line 65, in send_email
email.send(fail_silently=False)
email.send(fail_silently=False)
File "/Users/cheng/.virtualenvs/diandi/lib/python2.7/site-packages/django/core/mail/message.py", line 292, in send
File "/Users/cheng/.virtualenvs/diandi/lib/python2.7/site-packages/django/core/mail/message.py", line 292, in send
return self.get_connection(fail_silently).send_messages([self])
return self.get_connection(fail_silently).send_messages([self])
File "/Users/cheng/.virtualenvs/diandi/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
File "/Users/cheng/.virtualenvs/diandi/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
new_conn_created = self.open()
new_conn_created = self.open()
File "/Users/cheng/.virtualenvs/diandi/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open
File "/Users/cheng/.virtualenvs/diandi/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open
self.connection.login(self.username, self.password)
self.connection.login(self.username, self.password)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 622, in login
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 622, in login
raise SMTPAuthenticationError(code, resp)
raise SMTPAuthenticationError(code, resp)
SMTPAuthenticationError: (535, '5.7.3 Authentication unsuccessful')
I tested the username and password via the web portal and it works. So I am curious if there is anything wrong in my settings file (or maybe I missed something?)
UPDATE: Thanks guys, a STUPID mistake that I made:
Username should be without the @blah.com
part...
Use this,
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'Your gmail address'
EMAIL_HOST_PASSWORD = 'Your password'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
Make sure you are providing a vaild gmail id and its password
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.