POST /api/message/send.php


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



Request parameters


Parameter
Value
autoresponder_id
Autoresponder ID. Required.
from
Object 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.
to
List of message recipients. Required.
context
Object of message variables. Structure is described in "Parameter context structure" section.
attachments
List of message attachment objects. Maximum size of one attachment can be up to 16MB. Object structure is described in "Parameter attachments structure" section.



Parameter from structure


Parameter
Value
email
Sender email address. Required
name
Sender name. Required.



Parameter context structure


Parameter
Value
...
Value will be normalized to string.



Parameter attachments structure


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


Parameter
Value
content
Attachment content in Base64 encoding.
url
Public, not password protected URL to file. Only http and https protocols are allowed.
filename
Attachment name in message. Required.



Example request


$username = 'YOUR_USERNAME';
$password = 'YOUR_PASSWORD';
$location = 'https://<alamdomeen>.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);