我正在尝试从托管在 GoogleAppEngine 上的 web2py 应用程序发送邮件。但它不起作用。我使用了 web2py 提供的邮件功能。有人该怎么做吗?我在 GAE 文档中读到 python 邮件库不能与 GAE 一起使用,必须使用 GAE 邮件库。它也适用于 web2py 邮件吗?谢谢
问问题
2511 次
3 回答
5
web2py gluon.tools.Mail 类(也被 Auth 模块使用)在 GAE 和非 GAE 上开箱即用。您只需要传递正确的设置:
mail=Mail()
mail.settings.server="smtp.example.com:25" or "gae"
mail.settings.sender="you@example.com"
mail.settings.tls=True or False
mail.settings.login="you:password"
它支持多种编码、MIME 和附件。
于 2010-04-17T00:53:58.083 回答
3
web2pygluon.tools.Mail
类适用于 GAE。请参阅代码片段gluon.tools
第 310 行
try:
if self.settings.server == 'gae':
from google.appengine.api import mail
result = mail.send_mail(sender=self.settings.sender, to=to,
subject=subject, body=text)
这是在 GAE 上工作的正确设置
mail=Mail()
mail.settings.server="gae"
mail.settings.sender="you@example.com" #This must be the email address of a registered
#administrator for the application, or the address
#of the current signed-in user.
mail.settings.login="you:password"
请参阅 http://code.google.com/intl/en/appengine/docs/python/mail/emailmessagefields.html 发件人 发件人的电子邮件地址,发件人地址。这必须是应用程序注册管理员的电子邮件地址,或当前登录用户的地址。可以使用管理控制台将管理员添加到应用程序。当前用户的电子邮件地址可以通过用户 API 确定。
对不起!我的英文很差。我希望能有所帮助。
Celso Godinho (celso.gcosta@gmail.com) 2010 年巴西足球世界杯冠军
于 2010-04-27T22:47:35.770 回答
-1
您应该使用本机 App Engine 邮件程序: http ://code.google.com/appengine/docs/python/mail/sendingmail.html
于 2010-04-16T22:20:30.883 回答