Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Bulk Mail With Analytics via SendGrid

You can use SendGrid to power your emails on Google App Engine. Using SendGrid can improve your deliverability and provide transparency into what actually happens to those emails your app sends. You can see statistics on opens, clicks, unsubscribes, spam reports and more through either the SendGrid interface or its API.

Pricing

Google App Engine customers can send 25,000 emails every month for free. Create a SendGrid account * to claim the free emails and to see higher volume plans.

Prerequisites

To begin, you'll need to:

  1. Create a SendGrid account * and as a Google App Engine developer, you can start with 25,000 free emails per month
  2. Create a new application or use an existing app

Send an email

It's easy to get started with the PHP library for SendGrid to send emails from your App Engine apps.

With the prerequisites complete, make sure your development environment is set up on your local machine with the PHP client tools.

The last thing you'll need before writing code is to clone or download the SendGrid PHP library from GitHub. When you include this library in your app you'll be able to create SendGrid instances and send mail with simple commands.

At the top of your app's .php file, require the Sendgrid library:

require '../path/to/sendgrid-google-php/SendGrid_loader.php';

Now, from within your app, you can send email with the following few lines:

// Connect to your SendGrid account
$sendgrid = new SendGrid\SendGrid('username', 'password');

// Make a message object
$mail = new SendGrid\Mail();

// Add recipients and other message details
$mail->addTo('[email protected]')->
       addTo('[email protected]')->
       setFrom('[email protected]')->
       setSubject('Subject goes here')->
       setText('Hello World!')->
       setHtml('<strong>Hello World!</strong>');

// Use the Web API to send your message
$sendgrid->send($mail);

You'll want to add your own account details. Then edit the email address and other message content. Of course, you'll also need to run the update command to push your app to App Engine:

appcfg.py update your_application/

If you'd rather start with a full, working app, check out this sample Google App Engine app . For more information about email in your apps, browse the SendGrid documentation .

Get real-time

In addition to sending email, SendGrid can help you receive email or make sense of the email you’ve already sent. The two real-time webhook solutions can greatly enhance the role email plays in your application.

Event API

Once you start sending email from your app, you'll want to know more about how it's performing. The statistics within SendGrid are one of its best features. The Event API lets you see all this data as one giant firehose. Whenever a recipient opens or clicks an email, for example, SendGrid can send a small bit of descriptive JSON to your Google App Engine app. You can react to the event or store the data for future use.

There are many different applications of event data. Some common uses are to integrate email stats into internal dashboards or use it to respond immediately to unsubscribes and spam reports. Advanced users of the Event API raise the engagement of their emails by sending only to those who have clicked or opened within the last few months.

The Event API documentation shows how to set up the webhook, outlines the nine event types and shows the fields included in event callbacks.

Inbound Parse API

SendGrid is really good at sending email, but there's a lesser-known feature to receive email. The Inbound Parse API can be used for powerful, interactive applications. For example, automate support tickets from customer emails, or collect data via short emails employees dispatch from the road. NudgeMail's reminder application is even built entirely on the Parse API.

Like the Event API, the Parse API is a webhook that sends data to your application when something new is available. In this case, the webhook is called whenever a new email arrives at the domain you've associated with incoming email. Due to intricacies in the way DNS works for email, you need to assign all incoming mail to the domain or sub-domain you use for the Parse API.

Emails are sent to your application structured as JSON, with sender, recipients, subject and body as different fields. You can even accept attachments, within SendGrid’s limit of messages up to 20 MB in size.

The Parse API documentation has more details, including additional fields sent with every email, as well as instructions for DNS setup and usage.

* Google will be compensated for customers who sign up for a non-free account.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.