从GAE上的web2py发送电子邮件

时间:2010-04-16 20:56:36

标签: python google-app-engine web2py

我正在尝试从我在GoogleAppEngine上托管的web2py应用发送邮件。但它没有用。我使用了web2py提供的邮件功能。有人怎么做? 我在GAE文档中读到,python邮件库不能与GAE一起使用,必须使用GAE邮件库。它是否也适用于web2py邮件? 感谢

3 个答案:

答案 0 :(得分: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和附件。

答案 1 :(得分:3)

web2py gluon.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 寄件人     发件人的电子邮件地址,发件人地址。这必须是应用程序的注册管理员的电子邮件地址,或当前登录用户的地址。可以使用管理控制台将管理员添加到应用程序。可以使用Users API确定当前用户的电子邮件地址。

抱歉!我的英语非常糟糕。我希望能提供帮助。

Celso Godinho(celso.gcosta@gmail.com) 2010年巴西世界杯冠军足球赛

答案 2 :(得分:-1)

您应该使用本机App Engine邮件程序: http://code.google.com/appengine/docs/python/mail/sendingmail.html

相关问题