Django通过Gmail发送电子邮件的麻烦,总是垃圾邮件

时间:2013-12-14 17:16:50

标签: python django email gmail-imap

在Django中,我有一个通过Gmail帐户发送电子邮件的应用程序。 这是我的settings.py配置

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'user@gmail.com'
EMAIL_HOST_PASSWORD = 'thepassword'
EMAIL_PORT = 587

发送电子邮件的方式(在views.py中):

from_email = 'user@gmail.com' #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, ['the_gmail_user@gmail.com'])
msg.attach_alternative(html_content, "text/html")
msg.send()

用户始终收到垃圾邮件。 这是我做错了什么?

谢谢!

P.s:在Django 1.4,1.5和1.6中出现同样的问题,因此它与版本无关

1 个答案:

答案 0 :(得分:1)

您的代码没有错......

可能是您的电子邮件被其他用户或Google标记为垃圾邮件(发送的邮件过多?邮件内容?)。尝试其他电子邮件服务? Gmail并非真正适用于应用级电子邮件服务,而是供个人使用。

我最近切换到MailGun,他们的免费套餐有足够的容量。还有其他选择。

相关问题