User Manual - Sending Messages

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>",
    "tracking": 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>",
    "tracking": true
    }'

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 Lists 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>",
    "tracking": 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 gender 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 {firsname}!</h3></body></html>",
    "tracking": 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.

×

Subscribe

The latest tutorials sent straight to your inbox.