Get and Post in Mail Service

47 views
Skip to first unread message

Zeynel

unread,
Nov 18, 2010, 3:52:15 PM11/18/10
to Google App Engine
Hello,

I am trying to send email by using the examples in the tutorial:

http://code.google.com/appengine/docs/python/mail/overview.html


************************************************
class MainPage(webapp.RequestHandler):
def get(self):

message = mail.EmailMessage(sender="sen...@gmail.com",
subject="test email from app")
message.to = "rece...@gmail.com"
message.body = "Hello"

message.send()

def post(self):
user_address = "rece...@gmail.com"

confirmation_url = "http://support.example.com/"
sender_address = "sen...@gmail.com"
subject = "confirm your registration"
body = "Click on the link %s " % confirmation_url

mail.send_mail(sender_address, user_address, subject, body)
******************************************************

The first version works; but the second one works only if I change it
to "get":

def get(self):
user_address = "a...@gmail.com"
....

Can anyone explain how get and post work in this context. Thanks!

Erick Fleming

unread,
Nov 18, 2010, 4:45:59 PM11/18/10
to google-a...@googlegroups.com
what's your form and routing code look like?

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>

--
Erick Fleming

Zeynel

unread,
Nov 18, 2010, 5:31:21 PM11/18/10
to Google App Engine
On Nov 18, 4:45 pm, Erick Fleming <efleming...@gmail.com> wrote:
> what's your form and routing code look like?

Hi Erick,

That's the entire code. I hardcoded the emails; there is no form; I am
just trying to make sending/receiving email work.

For routing I have this:

application = webapp.WSGIApplication(
[('/', MainPage),
],
debug=True)

Robert Kluin

unread,
Nov 18, 2010, 11:03:01 PM11/18/10
to google-a...@googlegroups.com
It probably only works using the get method because you are making the
request by typing to the url into your browser.

Robert

Erick Fleming

unread,
Nov 18, 2010, 11:23:18 PM11/18/10
to google-a...@googlegroups.com
Robert is correct. You either need to have an HTML form in order to
create a POST request, or you could use a program like curl from the
command line.

Zeynel

unread,
Nov 19, 2010, 3:27:17 PM11/19/10
to Google App Engine
On Nov 18, 11:23 pm, Erick Fleming <efleming...@gmail.com> wrote:
> Robert is correct.  You either need to have an HTML form in order to
> create a POST request, or you could use a program like curl from the
> command line.

Thanks, Erick and Robert! I included the form
http://groups.google.com/group/google-appengine/browse_thread/thread/6cf068bf534e128c?hl=en#
and now it works.
Reply all
Reply to author
Forward
0 new messages