In Django, I have an app that send email through an gmail account. This is my settings.py configuration
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'thepassword'
EMAIL_PORT = 587
And the way to send emails (in views.py):
from_email = '[email protected]' #look that is equal to EMAIL_HOST_USER
template_html = 'my_template.html'
subject = u'The subject'
html_content = render_to_string(template_html, {})
msg = EmailMultiAlternatives(subject, html_content, from_email, ['[email protected]'])
msg.attach_alternative(html_content, "text/html")
msg.send()
The user always receive as SPAM. It's something that I'm doing wrong?
Thanks!
P.s: The same issue occurs in Django 1.4, 1.5 and 1.6, so it's version agnostic
Nothing wrong with your code...
Could be that your email has been flagged as spam by other users, or by Google (sending too many? Message content?). Try a different email service? Gmail isn't really designed for application level email service, but rather to be used by individuals.
I've recently switched to MailGun and their free tier has enough capacity. There are other options out there as well.