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
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.
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
You should use the native App Engine mailer: http://code.google.com/appengine/docs/python/mail/sendingmail.html
© 2022 - 2024 — McMap. All rights reserved.