Messages

Sending a message

POST https://api.mailersoft.com/api/v1/messages/

Sends an existing newsletter to subscriber, including all variables if supplied.

Parameters

Required Parameter Description
Yes apiKey
Yes id The ID of the newsletter which will be sent
Yes recipientEmail The email of the subscriber
No recipientName Name of the subscriber
No variables Array of variables of the subscriber that are used in newsletter

PHP code example

To send message to subscriber.

$ML_Messages = new ML_Messages( API_KEY );

$variables = array(
    'first' => 'first variable value',
    'second' => 'second variable value',
    'first_repeater' => array( 
       array( 'item1.1' => 'item value 1.1', 'item1.2' => "item value 1.2" ),
       array( 'item2.1' => 'item value 2.1', 'item2.2' => "item value 2.2" ),
    )
);
$result = $ML_Messages->setId( MESSAGE_ID )->setRecipient( 'test@example.com', 'Example' )->setVariables( $variables )->send();

Response example

{
	"Message": "Message Queued",
	"Ids": [349751]
}
{
	"errors": [Invalid recipient email "bad@email"]
}

Sending a message to many

POST https://api.mailersoft.com/api/v1/messages/

Sends an existing newsletter to many subscribers, including all variables if supplied.

Parameters

Required Parameter Description
Yes apiKey
Yes id The ID of the newsletter which will be sent
Yes batch Array of subscribers

PHP code example

To send message to many subscribers.

$ML_Messages = new ML_Messages( API_KEY );

$subscribers = array(
    array(
        'recipientEmail' => 'first@example.com',
        'recipientName' => 'First name',
        'variables' => array( 'item1' => 'value 1', 'item2' => "value2" )
    ),
	array(
        'recipientEmail' => 'second@example.com',
        'recipientName' => 'First name',
        'variables' => array( 'item1' => 'value 1', 'item2' => "value2" )
    )
);
$result = $ML_Messages->setId( MESSAGE_ID )->addRecipients( $subscribers )->send();

Response example

{
	"Message": "Message Queued",
	"Ids": [349771,349773]
}
{
	"Results": [Invalid recipient email "bad@email", Invalid recipient email "bad@email2"],
	"Ids": [349771]
}
{
	"errors": "No messages queued",
	"Results": [Invalid recipient email "bad@email", Invalid recipient email "bad@email2"]
}

Checking message status

GET https://api.mailersoft.com/api/v1/messages/

Gets status of sent message with subscriber information (if it was sent already).

Parameters

Required Parameter Description
Yes apiKey
Yes id The message queue ID, which was received by send method

PHP code example

To check message status.

$ML_Messages = new ML_Messages( API_KEY );

$result = $ML_Messages->setId( MESSAGE_QUEUE_ID )->checkRecipient();

Response example

{
	"status": "pending"
}
{
	"status": "sent",
	"subscriber": {
		"id": 29,
		"date": "2015-11-04 10:06:02",
		"email": "info@example.com",
		"name": "Recipient name",
		"register_date": "2015-01-12",
		"status": "unsubscribed"
	}
}