GET /api/message/send.php


Request parameters

Request body must be a JSON serialized string. Maximum allowed request body is 64MB.


ParameterValue
autoresponder_idAutomation ID. Required.
fromObject with sender data. Structure is described in "Parameter from structure" section. Sender data falls back to autoresponder configured values, if parameter is omitted from request.
toList of message recipients. Required.
contextObject of message variables. Structure is described in "Parameter context structure" section.
attachmentsList of message attachment objects. Object structure is described in "Parameter attachments structure" section.



Parameter from structure


ParameterValue
emailSender email address. Required
nameSender name. Required.



Parameter context structure


ParameterValue
...Value will be normalized to string.


Parameter attachments structure

Note! Either use content or url parameter. Using both is not allowed.


ParameterValue
contentAttachment content in Base64 encoding.
urlPublic, not password protected URL to file. Only http and https protocols are allowed.
filenameAttachment name in message. Required.



Response parameters


ParameterValue
codeError code. For successful request the value will be 101.
messageHuman-readable error message. For successful request the value will be "OK".
message_idsList of queued message IDs. Each value is a unsigned 64-bit long. Only included with successful API request.



Example request


$username = 'API_USERNAME';
$password = 'API_PASSWORD';
$location = 'https://<subdomain>.sendsmaily.net/api/message/send.php';
$query = array(
  'autoresponder_id' => 1,
  'from' => array(
    'email' => 'support@smaily.com',
    'name' => 'Sendsmaily',
  ),
  'to' => array('info@smaily.com', 'support@smaily.com'),
  'context' => array(
    'name' => 'John Doe',
    'city' => 'Tallinn'
  ),
  'attachments' => array(
    array(
      'content' => 'dGVzdA==',
      'filename' => 'Fail 1.txt',
    ),
    array(
      'url' => 'https://smaily.com/path/to/attachment.pdf',
      'filename' => 'Fail 2.pdf',
    ),
  ),
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $location);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

$result = curl_exec($ch);
curl_close($ch);



Example response


{
  "code": 101,
  "message": "OK",
  "message_ids": [140737488355328]
}