【发布时间】:2011-10-11 13:34:12
【问题描述】:
我正在尝试使用我的 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
我做错了什么?
谢谢!
【问题讨论】:
-
不是一个答案,但你能用另一个 SMTP 服务器试试吗? groups.google.com/group/comp.lang.python/browse_thread/thread/…