سؤال

My settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' 
EMAIL_USE_TLS = True 
EMAIL_HOST = 'smtp.gmail.com' 
EMAIL_PORT = 587 
EMAIL_HOST_USER = 'rakil@gmail.com' 
EMAIL_HOST_PASSWORD = '*******' 
DEFAULT_FROM_EMAIL = 'testing@testing.com

But a mail is not sent to the address, in the console the print.html is printing when I click on send_email, but it's not sending any email.

I am using Django 1.3.7 and Python 2.6.

I don't know the problem is with the version or some logic problem.

هل كانت مفيدة؟

المحلول

In settings.py

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

console.EmailBackend will print the mail in the console. So using

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

solved my problem. It is already documented here: Django docs: Email

نصائح أخرى

I personally just switched to my production server when this happened. Because this is a new IP location, Google attempted to protect my account by blocking the sign-in.

To fix this, I followed the steps in this answer:

First, enable access to less secure apps in your Google account here: https://www.google.com/settings/security/lesssecureapps

Since I had already done this, and my problem was now because of a new IP address, I had to manually confirm the next sign-in attempt using this link: https://accounts.google.com/DisplayUnlockCaptcha

See the linked answer for more information.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top