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 3392342
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:54:34+00:00 2026-05-18T03:54:34+00:00

I am reading the tutorial about Receiving Mail . I updated the app.yaml file

  • 0

I am reading the tutorial about Receiving Mail. I updated the app.yaml file as instructed:

application: hello-1-world
version: 1
runtime: python
api_version: 1

handlers:
- url: /favicon.ico
  static_files: static/images/favicon.ico
  upload: static/images/favicon.ico

- url: /_ah/mail/.+
  script: handle_incoming_email.py 
  login: admin

- url: /.*
  script: hw.py

inbound_services:
- mail

And created a handle_incoming_email.py

import cgi
import os
import logging
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.api import mail
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler

class ReceiveEmail(InboundMailHandler):
    def receive(self,message):
        logging.info("Received email from %s" % message.sender)
        plaintext = message.bodies(content_type='text/plain')
        for text in plaintext:
            txtmsg = ""
            txtmsg = text[1].decode()
            logging.info("Body is %s" % txtmsg)
            self.response.out.write(txtmsg)

application = webapp.WSGIApplication([
  ReceiveEmail.mapping()
], debug=True)

def main():
    run_wsgi_app(application)
if __name__ == "__main__":
    main()

I also have hw.py that I used to practice sending email. That one works.

Now I go to http://localhost:8081/_ah/admin/inboundmail and send an email to help@hello-1-world.appspotmail.com

Can anyone explain to me how I process this email? How do I access the content of the email? I have the code

self.response.out.write(txtmsg)

in handle_incoming_email.py but that does not print anything.

I would greatly appreciate if someone clarify how receiving email works.

For instance, in this question

class MailHandler (InboundMailHandler):
  def receive(self, message):
    sender = message.sender
    user_account = db.GqlQuery("SELECT * FROM Task WHERE user = :1", sender).fetch(5)

as far as I understand sender is the email of the sender. So, in my case, how do I access the sender email address.

Also, why do I need to have a separate script to handle incoming mail? Why can’t I put the ReceiveEmail handler in my hw.py script? If I do that, where do I put the line

application = webapp.WSGIApplication([
  ReceiveEmail.mapping()
], debug=True)

I would be grateful if you can help me with these questions.

(I asked the same question in GAE group but there were no answers.)

  • 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-05-18T03:54:35+00:00Added an answer on May 18, 2026 at 3:54 am

    Is help@hello-1-world.appspotmail.com a valid google user? GAE can receive/send mails only from the google user of your application.
    Your code seems correct.

    “Also, why do I need to have a separate script to handle incoming mail? Why can’t I put the ReceiveEmail handler in my hw.py” -> the main script is to handle url request, I think is much clearer in this way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading a tutorial http://www.raywenderlich.com/1914/how-to-save-your-app-data-with-nscoding-and-nsfilemanager about using NSCoding so that I can save
I'm reading a tutorial about Firefox extensions and one of the important files is
When reading the tutorial of Properties Tutorial from MSDN. I'm consused about the example.
I was reading sbt tutorial , and I wanted to understand the part about
I'm reading a tutorial about creating a shoutbox with jquery, php and ajax. In
I am just a beginner at windows programming and was reading a tutorial about
I`m a beginner reading a tutorial about Dates in JavaScript, and it gives this
I am reading the java tutorial about Wildcards in Generics. In the following code:
I am just reading a great tutorial about threads and have a problem with
According to the tutorial I am reading, the program below displays Hello Ima Reader.

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.