Receive an email from Google App engine, in php 1


There is not so much documentation on how to receive an email on Google App Engine (gae) with PHP. The official documentation is not really explicit, I guess it is because it is still experimental as I write.

After fighting some time, here is how to do it.

configure app.yaml with the following:

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

inbound_services:
- mail

Here, I redirect every received email to handle_incoming_email.php.

In handle_incoming_email.php, the content of the received email is available not in $_POST, but in file_get_contents('php://input')

With the help of Plancake email parser, it becomes easy to get the content:

$emailParser = new PlancakeEmailParser(file_get_contents('php://input'));
$email_body = $emailParser->getBody();

Et voila.

Fab
Latest posts by Fab (see all)

About Fab

Solutions Architect, I build great workflows for the news and media production industries. I play with data too.

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Receive an email from Google App engine, in php