我正在尝试使用我的gmail smtp和pyramid_mailer包从我的金字塔网站发送电子邮件。首先,如果有其他电子邮件解决方案的建议,请告诉我!我将以下内容添加到我的dev.ini文件中:
然后我这样发送消息:
mail.host = smtp.gmail.com
mail.username = user@gmail.com
mail.password = password
mail.port = 465
mail.ssl = True
然后我这样发送消息:
config.registry['mailer'] = Mailer.from_settings(settings)
以后会……
mailer = request.registry['mailer']
message = Message(subject="hello world",
sender="admin@mysite.com",
recipients=["someaddress@gmail.com"],
body="hello!")
mailer.send(message)
很不幸,我得到了以下异常:
SMTPServerDisconnected: please run connect() first
我做错了什么?
谢谢!