mattes
mattes

Reputation: 9429

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

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:  "[email protected]",
    To:       []string{"[email protected]"},
    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.

Upvotes: 2

Views: 384

Answers (1)

Dave W. Smith
Dave W. Smith

Reputation: 24966

That bit of smtplib.py is handling an error from rcpt(), which has tried sending rcpt TO:[email protected] 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).

Upvotes: 1

Related Questions