我正在尝试使用Flask服务器上的SendGrid发送电子邮件。我有一个非常简单的示例代码,如下所示:
sg = sendgrid.SendGridAPIClient(apikey='key')
data = {
"personalizations": [
{
"to": [
{
"email": "email@gmail.com"
}
],
"subject": "Hello World from the SendGrid Python Library!"
}
],
"from": {
"email": "sender@example.com"
},
"content": [
{
"type": "text/plain",
"value": "Hello, Email!"
}
]
}
response = sg.client.mail.send.post(request_body=data)
return jsonify(response)
这导致烧瓶中出现以下错误:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 2000, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1567, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1541, in handle_user_exception
handler = self._find_error_handler(e)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1476, in _find_error_handler
.get(code))
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1471, in find_handler
queue.extend(cls.__mro__)
AttributeError: class addinfourl has no attribute '__mro__'
我无法弄清楚这意味着什么。有人能指出我正确的方向吗?