felix
felix

Reputation: 11542

Sending email from an web2py on GAE

I am trying to send a mail from my web2py app hosted on GoogleAppEngine. But it is not working. I used the mail function that was given with the web2py. Does anybody how to do this? I read in the GAE Documentation that python mail library would not work with GAE and GAE mail library has to be used. Does it also applies to web2py mail? Thanks

Upvotes: 5

Views: 2546

Answers (3)

Celso
Celso

Reputation: 31

The web2py gluon.tools.Mail class works on GAE. See code snippet gluon.tools line 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)

This is the correct settings to work on GAE

mail=Mail()
mail.settings.server="gae"
mail.settings.sender="[email protected]" #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"

See http://code.google.com/intl/en/appengine/docs/python/mail/emailmessagefields.html sender The email address of the sender, the From address. This must be the email address of a registered administrator for the application, or the address of the current signed-in user. Administrators can be added to an application using the Administration Console. The current user's email address can be determined with the Users API.

Sorry! My english is very poor. I hope to help.

Celso Godinho ([email protected]) Brazil World Cup champion soccer 2010

Upvotes: 3

mdipierro
mdipierro

Reputation: 4248

The web2py gluon.tools.Mail class (that is used by the Auth module too) works on GAE and non-GAE out of the box. You just need to pass the correct settings:

mail=Mail()
mail.settings.server="smtp.example.com:25" or "gae"
mail.settings.sender="[email protected]"
mail.settings.tls=True or False
mail.settings.login="you:password"

It supports multiple encodings, MIME and attachments.

Upvotes: 5

dkamins
dkamins

Reputation: 21918

You should use the native App Engine mailer: http://code.google.com/appengine/docs/python/mail/sendingmail.html

Upvotes: -1

Related Questions