inbound_services:
- mail
- url: /_ah/mail/.+
script: myapp.views.handle_email
login: admin
'wsgi.input': <cStringIO.StringI object at 0x7f0524277938>,
'PATH_INFO': '/_ah/mail/tes...@myproject.localhost',
'wsgi.multiprocess': True,
'USER_EMAIL': '',
'wsgi.errors': <google.appengine.api.logservice.logservice._LogsStreamBuffer object at 0x7f0525c73090>,
'REQUEST_ID_HASH': 'B4788AA9',
'wsgi.run_once': False,
'TZ': 'UTC',
'APPLICATION_ID': 'dev~myproject',
'HTTP_CONTENT_LENGTH': '676',
'USER_IS_ADMIN': '0',
'HTTP_CONTENT_TYPE': 'message/rfc822',
'HTTPS': 'off',
'wsgi.url_scheme': 'http',
'SERVER_PROTOCOL': 'HTTP/1.1',
'DEFAULT_VERSION_HOSTNAME': 'localhost:8080',
'AUTH_DOMAIN': 'gmail.com',
'HTTP_X_APPENGINE_COUNTRY': 'ZZ',
'QUERY_STRING': '',
'PATH_TRANSLATED': '/mywork/googlecloud/myproject/myapp/views.py',
'INSTANCE_ID': '46aadbcae55fddddb13fdedbsfdsfdsdsadsa',
'REMOTE_ADDR': '0.1.0.20',
'USER_ID': '',
'REQUEST_METHOD': 'POST',
'USER_ORGANIZATION': '',
'SERVER_PORT': '8080',
'CONTENT_LENGTH': '676',
'REQUEST_LOG_ID': '9fe3f972f494b37acc49aa11c7e5abe4bcbada8d',
'SCRIPT_NAME': '',
'HTTP_HOST': 'localhost:8080',
'CONTENT_TYPE': 'message/rfc822',
'APPENGINE_RUNTIME': 'python27',
'SERVER_NAME': 'localhost',
'wsgi.multithread': True,
'wsgi.version': (1, 0),
'CURRENT_VERSION_ID': '47.190328127403515824',
'CURRENT_MODULE_ID': 'default',
'USER_NICKNAME': '',
'SERVER_SOFTWARE': 'Development/2.0',
'DATACENTER': 'us1'
'<bound method WsgiRequest._StartResponse of <google.appengine.runtime.wsgi.WsgiRequest object at 0x7f0525c732d0>>'
Hello
Can somebody direct me to solution how to receiving and handle emails inside Django app on App engine standard?
First place where I start was:
https://cloud.google.com/appengine/docs/standard/python/mail/receiving-mail-with-mail-api
All is working fine for webapp2 but I would like to handle it with Django view, cause rest of application is in Django.
When I use in app.yamlinbound_services:
- url: /_ah/mail/.+
script: myapp.views.handle_email
login: admin
the handle_email function get two arguments. First is type Dict with this content
'wsgi.input': <cStringIO.StringI object at 0x7f0524277938>,
'PATH_INFO': '/_ah/mail/tester@myproject.localhost',
Hello Yannick,
The reason to have handle for in Django view code, instead of webapp2
is my solicitude about cleanness and readability of code.
Now I have code in separate file. Somethink like:
class LogSenderHandler(InboundMailHandler):
def receive(self, mail_message):
for filename, content in mail_message.attachments:
content = content.decode()
""" call function in django view """
app = webapp2.WSGIApplication([LogSenderHandler.mapping()], debug=True)
It is like to have another, very different application and walk around
standard Django logging, debugging, urls, .... A little
schizophrenic.
If exist way how to do it without webapp2 I rather do it that way, but
if it does not exist, I will have to live with it.
Thank you for your interest.
2017-10-12 22:58 GMT+02:00 'Yannick (Cloud Platform Support)' via
Google App Engine <google-appengine@googlegroups.com>:
>> 'PATH_INFO': '/_ah/mail/tester@myproject.localhost',
> google-appengine+unsubscribe@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.