Documentation
Migrate from SendGrid.
The request body is flatter and the response carries an ID. Here is the send call before and after, then what carries over and what to check.
The send call, before and after
Before, with SendGrid's v3 mail send API (see SendGrid's docs for your library version):
After, with Mailtruss:
The main change is the body: SendGrid nests recipients in personalizations and the sender in an object, and takes the content as a list of typed parts. Mailtruss takes from, to, subject, html and text as plain fields. SendGrid answers a send with 202 and no body; Mailtruss returns the new email's id, which you can use to fetch its delivery trace. Other languages are under send email by language.
If you send over SMTP
Apps that use SendGrid's SMTP relay only need new settings. SendGrid's relay uses the literal username apikey with an API key as the password. Mailtruss takes any username with an API key as the password:
Details and framework examples are on the SMTP page and in the integration guides.
What maps to what
- Several recipients:
to,ccandbcctake lists. To send different messages to different people, usePOST /api/v1/emails/batch. - Dynamic templates: a Mailtruss template is sent by ID with a
variablesobject, and only the published version is ever sent. See Sending. - Categories and custom arguments: roughly
tags, which are name and value pairs you can filter by. - Unsubscribe groups:
topics, which people can switch on or off from the unsubscribe page without leaving everything. - Scheduling:
scheduled_attakes an ISO 8601 time. - Attachments: base64
contentwith afilename. - Marketing contacts and campaigns:
contacts,segmentsandbroadcasts.
Webhooks
SendGrid signs its event webhook with its own scheme, so verification code has to change. Mailtruss signs webhooks with the Standard Webhooks scheme, and the client libraries include a verifyWebhook helper. Events have different names (email.delivered, email.bounced, email.complained), so map them in your handler. See Webhooks.
A safe order to switch
- Create an account and verify your sending domain (DNS records). Verification here is separate from SendGrid's, and the records differ.
- Create a key and send a test to
delivered@mailtruss.test, so nothing reaches a real inbox. - Change the client, the key and the request body in one place in your code.
- Point your webhook handler at the new signing secret and event names, then send real mail.
- Keep SendGrid active for a few days while you watch the first real sends, then switch it off.
Comparing costs first? See Mailtruss vs SendGrid, which uses SendGrid's own published prices. Mailtruss's are on the pricing page.