Daniel Santos
Daniel Santos

Reputation: 15808

How send emails with Mautic with a custom text using API?

Is possible to add a custom text to a email before send it using mautic API.

We have an website where users may be notified when they receive a Gift. I would like to them receive this email with te gift name and price info.

This event is dispatched every time a gift is purchased, An email is sent by MauticAPI like :

$response = $emailApi->sendToContact($emailId, $contactId);

But I would like to add the gift name and price in the email body. How can I do it?

Upvotes: 1

Views: 2595

Answers (1)

Beny Cosma
Beny Cosma

Reputation: 86

The easiest way to add custom content to email is by using tokens. You can find more details here: https://developer.mautic.org/#extending-emails

You need to send in the body of the API request somethink like:

{
    "tokens": {
        "gift_name": "Cool Gift",
        "price": "$20"
    }
}

Then, in your email you can simply insert tokens using {}.

Example: You successfully purchased {gift_name} for {price}

Upvotes: 6

Related Questions