Sending via API
You can use Transactional Mailtarget with HTTP API. On each email that you sent, you can use either HTML or templates. For more details, see sending options on the API Reference Outbox.
Example Sending Messages via HTTP
Sending email using Mailtarget Transactional is very easy. You can use HTTP POST that leads to Mailtarget URL API.
Sending a HTML email:
curl -s -X POST https://trx.mailtarget.co/outbox -H 'Content-Type: application/json' -d '{ "accessToken": "$MT_APIKEY", "from": "$SENDER_EMAIL", "to": [ "$RECIPIENT_EMAIL" ], "labels": [ "$LABEL_EMAIL" ], "subject": "Hello", "content": "<html><body><h3>My First Email Sent by Mailtarget</h3></body></html>" }'
Sample response:
"message queued : 5a30ebc7f30e6a791fb54823"
Sending a template email:
curl -s -X POST https://trx.mailtarget.co/outbox -H 'Content-Type: application/json' -d '{ "accessToken": "$MT_APIKEY", "from": "$SENDER_EMAIL", "to": [ "$RECIPIENT_EMAIL" ], "labels": [ "$LABEL_EMAIL" ], "subject": "Hello", "templateId": "5a1b78c7f30e6a586be6299f" }'
Tracking true:
curl -s -X POST https://trx.mailtarget.co/outbox -H 'Content-Type: application/json' -d '{ "accessToken": "$MT_APIKEY", "from": "$SENDER_EMAIL", "to": [ "$RECIPIENT_EMAIL" ], "labels": [ "$LABEL_EMAIL" ], "subject": "Hello", "content": "<html><body><h3>My First Email Sent by Mailtarget</h3></body></html>", "track": true }'
Message Queue
When you send an email using Mailtarget Transactional, all emails will go into the queue.
You can send to multiple emails at once or by sending them dynamically one by one. Mailtarget use a special algorithm that can sort email queues in such a way that emails sent individually don't enter the bulk email queue.
If you frequently send multiple emails at once, email service provider will detect your domain sending spam. Therefore, we encourage you to email each one dynamically.
Batch Sending
You can email directly one by one dynamically or multiple recipients at once via Mailtarget Transactional. If you want to send all at once, you can use to and write many recipients.
Here is an example to send to multiple emails using to:
"to": [ "jon@example.com, jin@example.com, jun@example.com, jan@example.com" ],
Detail example of send an email to many using to:
curl -s -X POST https://trx.mailtarget.co/outbox -H 'Content-Type: application/json' -d '{ "accessToken": "$MT_APIKEY", "from": "$SENDER_EMAIL", "to": [ "jon@example.com, jin@example.com, jun@example.com, jan@example.com" ], "labels": [ "$LABEL_EMAIL" ], "subject": "Hello", "content": "<html><body><h3>My First Email Sent by Mailtarget</h3></body></html>", "track": true }'
Important to Note, when you send an email, the sender's name in the recipient's inbox will, by default, be displayed as your email address. If you wish to change it, you can follow the code below:
"from": "SENDER_NAME<$SENDER_EMAIL>"
After you follow the code above, the sender's name will automatically change to whatever you desire.
Mailing Lists
Mailing lists make it easy for you to send emails via email aliases. Transactional Mailtarget will send a copy of the email from alias email address to each member who subscribes mailing list. You can create and manage mailing lists on Dashboard Transactional Mailtarget.
Overview
To use mailing list you can create a mailing list address like all@example.com and add email addresses to the mailing lists. Each time you send an email to all@example.com, a copy of email will be received by each member.
Creating & Manage a List
You can create a mailing list by going to mailing list menu on Transactional Mailtarget. Then create a mailing list such as all@example.com then fill in the description. Click on mailing list email to enter into mailing list email. Click Add Contact to add members to mailing list.
Managing a List
You can manage your mailing list via mailing list menu in Transactional Mailtarget. Click edit to change mailing lists email address or change the description.
To change member's email address, you can log in to the mailing list. In the mailing list, you can click edit to change email, firstname or lastname member.
Sending to a List
To send transactional email to a mailing list, you can use the same way as to send individual emails.
More details, here is an example of sending an email to a mailing list:
curl -s -X POST https://trx.mailtarget.co/outbox -H 'Content-Type: application/json' -d '{ "accessToken": "$MT_APIKEY", "from": "$SENDER_EMAIL", "to": [ "all@example.com" ], "labels": [ "$LABEL_EMAIL" ], "subject": "Hello", "content": "<html><body><h3>My First Email Sent by Mailtarget</h3></body></html>", "track": true }'
Template Variable
You can use shortcodes to personalize email to each recipient. By default you can add a shortcode of First Name {{firstname}} and Last Name {{lastname}}.
| Shortcode | Description |
|---|---|
{{firstname}} | Recipient's first name. |
{{lastname}} | Recipient's last name. |
Additionally you can add your own shortcode by adding it to the data property. You can add more than one shortcode that you can use simultaneously.
Here is an example of adding a firstname shortcode:
curl -s -X POST https://trx.mailtarget.co/outbox -H 'Content-Type: application/json' -d '{ "accessToken": "$MT_APIKEY", "from": "$SENDER_EMAIL", "to": [ "$RECIPIENT_EMAIL" ], "labels": [ "$LABEL_EMAIL" ], "data": { "firstname": "Kinan" }, "subject": "Hello", "content": "<html><body><h3>Hello {{firstname}}!</h3></body></html>", "track": true }'
Unsubscribing
In Mailing List, you are required to add {{unsubscribe}} shortcode. The shortcode is used so that members of the mailing lists can unsubscribe from your mailing list.
If you use the template feature, unsubscribe shortcode will automatically be added to the end of the email.