【问题标题】:sending mails with different domain names in python在python中发送不同域名的邮件
【发布时间】:2016-10-25 09:15:39
【问题描述】:

我在发送具有不同域名的邮件时收到“服务器不支持 SMTP AUTH 扩展”。 例如,我使用 person@example.com 发送邮件。这里我的域是 example.com。

当我尝试发送邮件时,我收到“服务器不支持 SMTP AUTH 扩展”错误

这是我的代码

settings.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.somedomain.com'
EMAIL_HOST_USER = 'Admin@somedomain.com'
EMAIL_HOST_PASSWORD = '***********'
EMAIL_PORT = 25
EMAIL_USE_TLS = True

views.py

msg = "Hi,this is testing mail."
try:
    send_mail('Appointment mail',msg,'',['user@somedomain.com'])
    response = 'Message sent successfully.You will receive response in very soon.Thank you.' 
except Exception as e:
    response = e
return HttpResponse(response)

谁能帮帮我,提前谢谢!

【问题讨论】:

  • “我遇到问题”不是一个有用的描述。发布错误消息或准确描述失败的原因和时间。
  • 我已经添加了我的回溯,请检查并在到达 "send_mail()" 时收到此错误。我在异常块中添加了一条打印语句,但该打印语句也没有执行,我认为没有引发异常块。谢谢
  • 我收到身份验证错误,因为我在 settings.py 中提供的帐户无法访问不太安全的应用程序。这就是我收到身份验证错误的原因。我已经在我的帐户中授予了安全性较低的应用程序的访问权限,然后工作正常。
  • 感谢回复我的问题。

标签: django python-2.7 sendmail


【解决方案1】:

我认为这可以帮助你。 Getting 'str' object has no attribute 'get' in Django。您不能直接返回“str”作为响应。你需要HttpResponse

from django.http import HttpResponse
return HttpResponse(response)

希望这会有所帮助。

【讨论】:

  • 谢谢,现在我没有收到该错误,但我收到了另一个错误。
  • 为什么我收到“SMTPException:服务器不支持 SMTP AUTH 扩展”错误。任何建议。
  • 你能把stacktrace放上去吗?
  • 如果您不介意,请告诉我是否可以使用具有不同域名的 smtp 服务器发送邮件,例如:san@example.com、san@bluetree.com 等。
  • 我想你可以。但是您需要配置 SMTP 服务器。我认为这可以帮助你。 christiaan.com/thoughts/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-13
  • 1970-01-01
  • 2017-07-04
  • 1970-01-01
  • 1970-01-01
  • 2014-11-03
  • 2011-06-09
相关资源
最近更新 更多