# Transactional emails via API

**URL:** <https://forum.mautic.org/t/transactional-emails-via-api/6763>\
**Category:** General Discussion\
**Created:** [December 6, 2016, 2:30am UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763 "2016-12-06T02:30:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![seboraid](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@seboraid](https://forum.mautic.org/u/seboraid)\
**Post date:** [December 6, 2016, 2:30am UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/1 "2016-12-06T02:30:29Z")

</div>

Hi !  
  
  
  
Is there any way to create templates with placeholders to send transactional emails like Welcome emails, or recover password emails ?  
  
  
  
It is very helpfull to have the transactional emails layout separated from the backend code and just call a restfull API to send this kind of emails to a single user when needed.

---

<div class="post-metadata">

**Author:** ![seboraid](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@seboraid](https://forum.mautic.org/u/seboraid)\
**Post date:** [December 6, 2016, 2:30am UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/2 "2016-12-06T02:30:29Z")

</div>

Hi !

Is there any way to create templates with placeholders to send transactional emails like Welcome emails, or recover password emails ?

It is very helpfull to have the transactional emails layout separated from the backend code and just call a restfull API to send this kind of emails to a single user when needed.

---

<div class="post-metadata">

**Author:** ![mrmirz](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mrmirz](https://forum.mautic.org/u/mrmirz)\
**Post date:** [December 23, 2016, 10:55pm UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/3 "2016-12-23T22:55:23Z")

</div>

I am also trying to figure out how to do this. Anyone have any info?

---

<div class="post-metadata">

**Author:** ![MarkLL](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MarkLL](https://forum.mautic.org/u/MarkLL)\
**Post date:** [December 24, 2016, 8:54am UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/4 "2016-12-24T08:54:33Z")

</div>

Hi @mrmirz the Mautic API does support sending an email to a contact. Api call is sendToContact($id, $contactId) in the emails context. So something like

```auto
// create context
$emailApi = $api->newApi('emails', $auth, $apiUrl);
// now send a known email ($id) to a known contact ($contactId)
$response = $emailApi->sendToContact($Id, $contactId);
```

so assuming you set up your email(s) correctly it should work like a charm.

---

<div class="post-metadata">

**Author:** ![mrmirz](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mrmirz](https://forum.mautic.org/u/mrmirz)\
**Post date:** [December 24, 2016, 5:27pm UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/5 "2016-12-24T17:27:07Z")

</div>

Hi @MarkLL thanks for the reply!

I did find that request in the API, but what I’m specifically looking for is whether we can pass data to a placeholder in the template via the API. As @seboraid mentioned, for a forgot password feature we’d need to dynamically insert a forgot password link into the email template. There’s other examples we want to achieve but we’d need to be able to pass some data from our database into the email template when programmatically triggering the email.

I’m also trying to figure out how to deal with the unsubscribes if I manage both my application’s transactional emails as well as marketing automation through Mautic. As I understand it, users are unsubscribed from all sending if they unsubscribe from one of the emails. I assume we’d need to run two instances of Mautic to avoid not being able to send them basic transactional emails.

---

<div class="post-metadata">

**Author:** ![mrmirz](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mrmirz](https://forum.mautic.org/u/mrmirz)\
**Post date:** [December 27, 2016, 7:10pm UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/6 "2016-12-27T19:10:22Z")

</div>

Anyone know if this is possible?

---

<div class="post-metadata">

**Author:** ![swup](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@swup](https://forum.mautic.org/u/swup)\
**Post date:** [June 22, 2017, 8:34am UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/7 "2017-06-22T08:34:03Z")

</div>

We are also wondering whether this is possible, i.e. passing temporary content such as the above password reset link example via placeholder variables to a transactional email?

---

<div class="post-metadata">

**Author:** ![Adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Adrien](https://forum.mautic.org/u/Adrien)\
**Post date:** [August 25, 2017, 3:14am UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/8 "2017-08-25T03:14:10Z")

</div>

+1

---

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [July 1, 2020, 3:32pm UTC](https://forum.mautic.org/t/transactional-emails-via-api/6763/9 "2020-07-01T15:32:27Z")

</div>

Hey @mrmirz

Did you create two Mautic instances to solve the problem regarding unsubscribed users? Or did you solve it some other way?
