I'm trying to send emails using Django without success.
I configured the settings.py file as below:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = "xxx@gmail.com"
EMAIL_HOST_PASSWORD = "xxx"
EMAIL_PORT = 587
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
I wrote a very simple view to test email sending:
def send_email_test(request):
from_email = "xxx@gmail.com"
to = "yyy86@gmail.com"
send_mail("test oggetto", "test messaggio", from_email, [to], fail_silently=False)
print "email sent"
return render_to_response('index.html', context_instance=RequestContext(request))
On my server console I can see this log:
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: test oggetto
From: xxx@gmail.com
To: yyy@gmail.com
Date: Thu, 09 Jul 2015 09:18:47 -0000
Message-ID: <20150709091847.28525.42497@MyServer>
test messaggio
-------------------------------------------------------------------------------
email sent
Anyway, I do not receive the mail on my email account.
Any suggestion?