我想用我的gmail smtp和pyramid_mailer軟件包從我的金字塔網站發送電子郵件。首先,如果有人對電子郵件解決方案有其他建議,請告訴我!無法用pyramid_mailer和gmail發送電子郵件
添加以下到我的dev.ini:
mail.host = smtp.gmail.com
mail.username = [email protected]
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="[email protected]",
recipients=["[email protected]"],
body="hello!")
mailer.send(message)
不幸的是,我得到以下例外:
SMTPServerDisconnected: please run connect() first
我在做什麼錯?
謝謝!
不是一個答案,但你可以與其他SMTP服務器試試嗎? http://groups.google.com/group/comp.lang.python/browse_thread/thread/4791505038b2fca5 –