相关疑难解决方法(0)

无法使用金字塔邮件程序和 gmail 发送电子邮件

我正在尝试使用我的 gmail smtp 和金字塔邮件程序包从我的金字塔网站发送电子邮件。首先,如果有人对电子邮件解决方案有其他建议,请告诉我!

我将以下内容添加到我的 dev.ini 中:

mail.host = smtp.gmail.com
mail.username = user@gmail.com
mail.password = password
mail.port = 465
mail.ssl = True
Run Code Online (Sandbox Code Playgroud)

然后我像这样发送消息:

config.registry['mailer'] = Mailer.from_settings(settings)
Run Code Online (Sandbox Code Playgroud)

然后...

mailer = request.registry['mailer']
message = Message(subject="hello world",
                      sender="admin@mysite.com",
                      recipients=["someaddress@gmail.com"],
                      body="hello!")
mailer.send(message)
Run Code Online (Sandbox Code Playgroud)

不幸的是,我得到以下异常:

SMTPServerDisconnected: please run connect() first
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

谢谢!

python gmail smtp pyramid

3
推荐指数
1
解决办法
1574
查看次数

标签 统计

gmail ×1

pyramid ×1

python ×1

smtp ×1