2013-12-14 89 views
0

在Django中,我有通过Gmail帐户发送电子邮件的应用程序。 这是我的settings.py配置麻烦和Django通过Gmail电子邮件,始终为垃圾邮件

EMAIL_USE_TLS = True 
EMAIL_HOST = 'smtp.gmail.com' 
EMAIL_HOST_USER = '[email protected]' 
EMAIL_HOST_PASSWORD = 'thepassword' 
EMAIL_PORT = 587 

,并发送电子邮件(在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() 

用户总是收到垃圾邮件。 这件事情,我做错了吗?

谢谢!

PS:发生在Django 1.4,1.5和1.6同样的问题,所以它的版本无关

回答

1

没有错,你的代码...

可能是您的电子邮件已被其他标记为垃圾邮件用户,或由谷歌(发送太多?留言内容?)。尝试不同的电子邮件服务? Gmail没有真正专为应用级电子邮件服务,而是由个人使用。

我最近切换到MailGun和他们的自由层有足够的容量。还有其他选项。

+0

感谢@Trik,我如果您使用山魈目前使用的山魈 – azuax

+0

,请务必将您的DKIM和SPF记录。 – souldeux

相关问题