Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:17:41+00:00 2026-06-18T16:17:41+00:00

I am hosting a website on Google Apps Engine and am trying to use

  • 0

I am hosting a website on Google Apps Engine and am trying to use Python’s mail API to take POST data and send an email.

Here is my script:

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import mail

class SendEmail(webapp.RequestHandler):
    def post(self):

        name = self.request.get('name')
        # self.response.out.write(name)
        email = self.request.get('email')
        tempSubject = self.request.get('subject')
        msg = self.request.get('message')

        if name is None:
            self.response.out.write("Error: You did not enter a name.")
        elif email is None:
            self.response.out.write("Error: You did not enter an email.")
        elif tempSubject is None:
            self.response.out.write("Error: You did not enter a subject.")
        elif msg is None:
            self.response.out.write("Error: You did not enter a message.")
        else:
            _subject = "Msg from: " + name + "Re: " + tempSubject

            message = mail.EmailMessage(sender = "foo@bar.com", to = "bar@foo.com", subject = _subject, body = msg, reply_to = email)
            message.send()

def runApp():
    application = webapp.WSGIApplication([('/email', SendEmail)], debug=True)
    run_wsgi_app(application)

if __name__ == '__main__':
    runApp()

And here is the traceback from the log on the server:

<type 'exceptions.NameError'>: name 'name' is not defined
Traceback (most recent call last):
  File "/base/data/home/apps/s~alex-young/1.365202894602706277/email.py", line 5, in <module>
    class SendEmail(webapp.RequestHandler):
  File "/base/data/home/apps/s~alex-young/1.365202894602706277/email.py", line 14, in SendEmail
    if name is None:

I ran the script locally with no errors, but once I try to run it on the server it keeps insisting the name variable I declared doesn’t exist. Any idea why this happens?

Also, if I comment out that line, it says email doesn’t exist, and so forth

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:17:42+00:00Added an answer on June 18, 2026 at 4:17 pm

    As it turns out, sometimes I used spaces to indent and other times I used tabs. Python didn’t like that. Here is the final code:

    import cgi
    from google.appengine.ext import webapp
    from google.appengine.ext.webapp.util import run_wsgi_app
    from google.appengine.api import mail
    
    class SendEmail(webapp.RequestHandler):
        def post(self):
            name = self.request.get('name', '')
            email = self.request.get('email', '')
            tempSubject = self.request.get('subject', '')
            msg = self.request.get('message', '')
    
            if name is None:
                self.response.out.write("Error: You did not enter a name.")
            elif email is None:
                self.response.out.write("Error: You did not enter an email.")
            elif tempSubject is None:
                self.response.out.write("Error: You did not enter a subject.")
            elif msg is None:
                self.response.out.write("Error: You did not enter a message.")
            else:
                _subject = "Message from: " + name + ", Re: " + tempSubject
                msg += "\n\nI can be reached at "
                msg += email
    
                message = mail.EmailMessage(sender = "foo@bar.com", to = "bar@foo.com")
                message.subject = _subject
                message.body = msg
                message.send()
    
                self.redirect('/')
    
    def runApp():
        application = webapp.WSGIApplication([('/email', SendEmail)], debug=True)
        run_wsgi_app(application)
    
    if __name__ == '__main__':
        runApp()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Google App Engine free 1GB bandwidth hosting website if we have external image
I'm hosting my website using Google App Engine. It's a pretty simple website, but
I use this method to send a mail on my website : $message=Hello; $headers='From:
i want to use google app hosting , but i have read that they
I have an application that runs on a shared hosting website - it is
I am developing a chat website using jsp/servlet.I will be hosting my website on
We are hosting a .NET website on Windows Server 2008 R2 (IIS 7.5) www.ourwebsite.com
I've transferred the website to new hosting... well I've changed the wp-config as it
I am running a website on shared hosting at GoDaddy (not my choice, because
I am hosting an Asp.Net website in IIS 6.0 We have to reset the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.