To do this I was lost, I don't know anything about Python. But, how? Take a look around you'll probably find something, return always to the Google App Engine Documentation. Yes, the Send Mail section is available. Let's see it.
Mail Api docs, give you the sample from the overview! Here's what I found
from google.appengine.api import mail
class ConfirmUserSignup(webapp.RequestHandler):
def post(self):
user_address = self.request.get("email_address")
if not mail.is_email_valid(user_address):
# prompt user to enter a valid address
else:
confirmation_url = createNewUserConfirmation(self.request)
sender_address = "support@example.com"
subject = "Confirm your registration"
body = """
Thank you for creating an account! Please confirm your email address by
clicking on the link below:
%s
""" % confirmation_url
mail.send_mail(sender_address, user_address, subject, body)
Before doing anything! You need to know, that the Send mail function isn't included by default so when running your server, you should add the following command
dev_appserver.py --enable_sendmailOr your mail won't be sent.
Then create a new Google App Engine Application. If you don't know how, here's a quick startup to create your Google App Engine application in minutes.
Trouble in manipulating this code? No, don't do, you don't need. First we are going simply to test the send_mail function, second we are going to use the Django Frameword and not the Google one.
Here's the code, that I use, simple and clean
from google.appengine.api import mail
print 'Content-Type: text/plain'
print ''
print 'I think the email was sent or going to!'
mail.send_mail("omar.abid2006@gmail.com", "omar.abid2006@gmail.com", "Google Coder", "Googler Coder Welcome")
Here's the list, don't be stupid!
Ok, here's the first goal and it was done, more to come in the future.
2 comments:
Acutally this solution wasn't working on windows machines since Windows uses SMTP instead of the UNIX sendmailer.
And with SMTP it wasn't working either cause Google hasn't fixed issues 626 and 1061 yet.
But since yesterday there exists a working solution for Windows as Byron Jones wrote a new version of his Fake Windows Sendmailer.
For details see my post and this thread of app-engine-patch.
Hi
I follow you steps to send a mail from Google app engine, But I cant send.
Step 1: I create a sample py file for sending a mail that you gave for example.
I start a app engine in local, its runs successfully but mail was not send
Note: I am using Windows xp
Post a Comment