Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Google's app engine - Email Sending


  • Please log in to reply
2 replies to this topic

#1 Yonatan


    CC Regular

  • Member
  • PipPipPip
  • 37 posts
  • Location:Israel
  • Programming Language:C, Java, C++, C#, JavaScript, PL/SQL, Visual Basic .NET
  • Learning:Python, JavaScript

Posted 09 September 2012 - 07:51 PM

So im pretty new to python, im using the appengine as a hosting for my site.
I am experienced with the normal programming languages and know my way around ASP.net but I do not have much experience with python.

I am looking for help / detailed tutorial for beginners in order to make a "Contact Form":
The user enters his own e-mail, e-mail's topic and body and the site needs to submit this details (from the admin's e-mail to the same e-mail). This can be done easily with PHP but because appengine do not support PHP I need to this with python with the structure of the appengine.

Posted Image

I need some one who know his way around appengine and is able to help me or send me a detailed tutorial.

Thanks in advance.
  • 0

#2 tux


    CC Regular

  • Member
  • PipPipPip
  • 29 posts
  • Programming Language:Java, Python, Visual Basic .NET, Fortran, Bash
  • Learning:C++

Posted 12 September 2012 - 01:44 PM

Have you checked this site:

Currently I don't have a time to write a tutorial.
  • 0

#3 tux


    CC Regular

  • Member
  • PipPipPip
  • 29 posts
  • Programming Language:Java, Python, Visual Basic .NET, Fortran, Bash
  • Learning:C++

Posted 13 September 2012 - 07:39 AM

Here is a short tutorial:

1. Download Google app engine http://googleappengi...ngine-1.7.1.msi (Windows version)

2. Inside folder google_appengine make folder and give a name (I used helloWorld)
3. Make folder named templates
4. In folder templates make contact.html which will contain following code:

<!doctype html>
	 <title>Leave a message</title>
	 <meta charset="utf-8"/>
	 <form method="post">
	 <input name="mail" placeholder="Enter your email">
<input name="subject" placeholder="Subject">
<input name="name" placeholder="Enter your name">
<textarea name="message" style="height:200px; weight=500px;" placeholder="Enter your message">
<input type="submit" value="Send"/>


5.Make file app.yaml inside your project folder (outside templates folder) which will contain:

application: <if your code is located at test.appspot.com then write test>
version: 1
runtime: python27
api_version: 1
threadsafe: true

- name: jinja2
version: latest

- url: /.*
script: helloworld.app

6. Make helloWorld.py :

import webapp2
import jinja2
import os
from google.appengine.api import mail

jinja_environment = jinja2.Environment(autoescape=True,loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))

class contact(webapp2.RequestHandler):
template = jinja_environment.get_template('contact.html')
def get(self):
def post(self):
# takes input from user

# not tested
if not mail.is_email_valid(userMail):
  self.response.out.write("Wrong email! Check again!")

message.body="""Thank you!
	 You have entered following information:
	 Your mail: %s
	 Subject: %s
	 Name: %s
	 Message: %s""" %(userMail,subject,name,userMessage)
self.response.out.write("Message sent!")

app = webapp2.WSGIApplication([('/contact',contact)], debug=True)

Change this line:

Your mail must be one of types:

The email address of the sender, the From address. The sender address must be one of the following types:
  • The address of a registered administrator for the application. You can add administrators to an application using the Administration Console.
  • The address of the user for the current request signed in with a Google Account. You can determine the current user's email address with the Users API. The user's account must be a Gmail account, or be on a domain managed by Google Apps.
  • Any valid email receiving address for the app (such as **@APP-ID.appspotmail.com).
  • Any valid email receiving address of a domain account, such as support@example.com. Domain accounts are accounts outside of the Google domain with email addresses that do not end in @gmail.com or @APP-ID.appspotmail.com.
Upload your application using:

appcfg.py update helloworld/

Here you can test code:

  • 0

Also tagged with one or more of these keywords: asp.net

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download