Mailjet is a third-party global email service that offers App Engine users a free tier with 25,000 emails each month. In addition, Mailjet also offers:
- European data privacy compliance.
- Email and deliverability features such as customizable priority settings and automated throttle management.
- A comprehensive API resource library in Go, PHP, Nodejs, Java, Python, Ruby to manage sub-accounts, authentication, contacts, campaigns, custom payloads, statistics, real time events and parsing through the Event API.
- 24/7 follow-the-sun support in 4+ languages.
- Ability to send emails from domains other than
gmail.com
.
Before you begin
Before you send mail with Mailjet:
Create a Mailjet account. As an App Engine developer, you can start with 25,000 free emails per month.
In Mailjet, add and verify the sender email address.
Note your API key and secret from your Mailjet SMTP Settings.
Select or create a new GCP project in the Google Cloud Platform Console and then ensure an App Engine application exists and billing is enabled:
The Dashboard opens if an App Engine application already exists in your project and billing is enabled. Otherwise, follow the prompts for choosing a region and enabling billing.
Add your MailJet API key and secret as environment variables to your
app.yaml
file.Add the required jersey REST client modules to your application. For example, if you use Maven, add to the project's pom.xml:
Configure your Mailjet settings, such as the API key and domain name in your
app.yaml
file:Import the Mailjet library in your application code:
Sending mail
To send a message in your application code:
Create a new Mailjet client.
Specify the details and contents of the message, including the sender email and name, subject, message body, and recipients.
Retrieve the server response to check the message status.
For example:
Statistics
The response payload of a Mailjet Send API call provides a
MessageID
. You can use theMessageID
to access information and statistics about the message.Use the GET operation on
/message
to get basic information about a message such as the sender, recipient, and message size. To learn more about message statistics, including sample API responses, refer to the Mailjet API guide.Event API
The Mailjet Event API offers real-time notification through HTTP requests (webhooks) on any events related to the messages you sent, such as when messages are sent or opened. This event notification works for all kind of messages, from transactional to marketing campaigns.
Use the Event API to achieve specific actions efficiently, such as logging the marketing messages sent to your customers, or updating the unsubscribed contacts in your customer relationship management (CRM) system. Instead of polling the Mailjet API a few times a day, data is pushed as events happen, in near real-time.
You can also group events together, which is useful when sending larger volumes. For further instructions, see the Mailjet documentation.
Parse API for inbound emails
You can also receive and parse emails with Mailjet and have the content delivered to a webhook. Mailjet organizes all the information so you can save it to your CRM or database.
Like the Event API, the Parse API notifies in near real-time to a defined webhook that sends data back to your application when a new message matches a predefined route. Emails are sent to your application structured as a JSON packet with all the useful information you need, such as the sender, recipient, subject, body and headers.
For more information, including additional fields sent with every email, and instructions for DNS setup and usage, see Mailjet’s Parse API documentation.