Google App Engine mail.Send在python2.7/smtplib.py中返回”TypeError: unhashable instance”。

huangapple go评论77阅读模式
英文:

Google App Engine mail.Send returns "TypeError: unhashable instance" in python2.7/smtplib.py

问题

我正在尝试通过Google App Engine开发服务器本地发送邮件:

dev_appserver.py --show_mail_body true --smtp_host=xxx --smtp_port=25 --smtp_user=xxx --smtp_password=xxx app.yaml

if err := mail.Send(c, &mail.Message{
    Sender:  "xxx@xxx.com",
    To:       []string{"xxx@xxx.com"},
    Subject:  "Test",
    Body:     "Text Body",
    HTMLBody: "HTML Body",
}); err != nil {
    c.Errorf("%v", err)
}

不幸的是,这导致了以下错误:

File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 731, in sendmail
    senderrs[each] = (code, resp)
TypeError: unhashable instance

有人可以帮我修复这个问题吗?--enable_sendmail true可以工作。Traceback

英文:

I am trying to locally send mail via Google App Engine Development Server:

dev_appserver.py --show_mail_body true --smtp_host=xxx --smtp_port=25 --smtp_user=xxx --smtp_password=xxx app.yaml


if err := mail.Send(c, &mail.Message{
	Sender:  "xxx@xxx.com",
	To:       []string{"xxx@xxx.com"},
	Subject:  "Test",
	Body:     "Text Body",
	HTMLBody: "HTML Body",
}); err != nil {
	c.Errorf("%v", err)
}

Unfortunately this results in the following error:

  File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 731, in sendmail
    senderrs[each] = (code, resp)
TypeError: unhashable instance

Can somebody please help me fix this? --enable_sendmail true works btw. Traceback.

答案1

得分: 1

smtplib.py中的那部分代码处理了rcpt()的错误,该错误是由于尝试将rcpt TO:xxx@xxx.com发送到smtp而引起的。所以有两个问题:rcpt在抱怨什么,以及unhashable instance是什么意思。对于后者,我建议提交一个错误报告。代码不应该这样做。对于前者,我建议在smtplib.pysenderrs[each] = (code, resp)上面加入一些简单的print调试语句。可能存在一些简单的上游错误,smtp正在显示给你,绕过这些错误可能会避免解决无法哈希的实例的问题(我猜测是由GAE端的代码引起的)。

英文:

That bit of smtplib.py is handling an error from rcpt(), which has tried sending rcpt TO:xxx@xxx.com to smtp. So there are two issues: what's rcpt complaining about, and what's with the unhashable instance. For the latter, I recommend filing a bug report. The code shouldn't do that. For the former, it'd be really tempted to put some simple print debugging into smtplib.py right above senderrs[each] = (code, resp). There might be some simple upstream error that smpt is showing you, the bypassing of which might obviate the need to sort out the unhashable instance (which I'm guessing is caused by code on the GAE side).

huangapple
  • 本文由 发表于 2014年11月29日 04:21:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/27195432.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定