0

I currently am using django-password-reset to assist users when they forget a password. Everything worked just fine while in development but now I am having issues setting up the email backend on my production server.

When a user enters their username or email into the password reset form and push the 'Recover Password' button that would normally trigger the password-reset email, the page starts to load infinitely. I am attempting to use a gmail account as my smtp server. I am assuming that there is some sort of issue with my settings.py file.

settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

EMAIL_HOST = 'smtp.gmail.com'

EMAIL_PORT = 465

EMAIL_HOST_USER = 'example@gmail.com'

EMAIL_HOST_PASSWORD = 'mypassword'

EMAIL_USE_TLS = True

DEFAULT_FROM_EMAIL = 'example@gmail.com'

If you have any idea what is wrong with my configuration or any other ways to set up my email backend advice would be greatly appreciated! Thanks

  • I tried to add SERVER_EMAIL and unfortunately the exact same problem still occurred. – Michael Sullivan Jan 08 '15 at 21:15
  • Have you tried using port 587? – Brandon Taylor Jan 08 '15 at 21:16
  • Tried that as well.. still seeing the exact same issue – Michael Sullivan Jan 08 '15 at 21:18
  • Hm, interesting. Did you already stumble upon this thread / this post on SO? http://stackoverflow.com/a/23402208/870769 Is there anything that helps? I just vaguely remember a friend telling me about troubles setting it up w/ gmail, but I can't remember his solution... testing it through the ``shell`` or maybe checking the mail logs from the server seems a good start, though. – sthzg Jan 08 '15 at 21:19
  • I just went through and nothing solved the issue. When I use the django shell on my production server and attempt to send_mail() from the console it causes it to freeze until I use a keyboard interrupt. – Michael Sullivan Jan 08 '15 at 21:28
  • Do you think it may just be easier to using something like django-ses? Or will that potentially give me the same kind of issues I am having now? – Michael Sullivan Jan 08 '15 at 21:43
  • I just tested a bit locally. When I try to use Gmail to send a mail through Django (tested in ``./manage.py shell``) I get the same error (connection hanging). When I then switch to my google account https://security.google.com/settings/security/secureaccount to 'check latest activity' (the second accordion tab), I see that my connection was blocked by google. Do you see a similar message? – sthzg Jan 08 '15 at 22:06
  • I checked and double checked and I do not see that message. – Michael Sullivan Jan 08 '15 at 22:12
  • 1
    Then I guess I am out of ideas. :) I got it working locally with activating less secure logins here (https://www.google.com/settings/security/lesssecureapps), using port ``EMAIL_PORT = 587`` and adding the ``SERVER_EMAIL = 'my@gmail.com'``. Will follow this thread and hope you can solve the troubles. (Since the comments didn't lead to the solution I will remove them in the next days). – sthzg Jan 08 '15 at 22:31
  • similar question http://stackoverflow.com/questions/19264907/python-django-gmail-smtp-setup – Aaron Lelevier Jan 08 '15 at 23:52
  • 2
    If it helps, strongly suggesting using an email service like SendGrid instead of gmail. It's free for low volume, and won't have to store gmail credentials in your code base or risk locking out your gmail account. – bvanvugt Jan 09 '15 at 04:13

1 Answers1

0

This works locally at least.

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'something@gmail.com'
EMAIL_HOST_PASSWORD = 'something'
EMAIL_USE_TLS = True
elpaquete
  • 241
  • 2
  • 9
  • I tried this exact setup and unfortunately I still am receiving the same error. If there any other settings that I could have enabled that could potentially be causing this issue? – Michael Sullivan Jan 09 '15 at 20:36