This guide describes how to use the Mail API to send and receive mail.
Before you begin
You must register your sender emails as authorized senders. For more information, see who can send email.
Sending mail
PHP's built-in mail()
function can send emails via App Engine Mail API. This should work well with
most existing code as long as it conforms to the restrictions listed in the
Sending mail.
Alternatively, you can make direct calls to the Mail API:
Receiving mail
You can set up your app to receive incoming email at addresses in the following format:
anything@appid.appspotmail.com
To receive email:
Enable incoming mail in your app's
app.yaml
file. Add the following to theinbound_services
:In your configuration file, create mappings from URL paths that represent email addresses to handlers in your app's code. The pattern
/_ah/mail/.+
matches all incoming email addresses:Implement code for the handlers you specified in your application code.
You can read the MIME data from php://input and parse the email content using Mailparse.