英文:
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.py
的senderrs[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).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论