https://<subdomain>.sendsmaily.net/api/campaign.php


POST method must be used for this query.


Parameters

All parameters must be URL encoded.


Parameter

Value

subject

Email subject. Required. Text field.

from

Sender From address. Required. Must be added first in Smaily > Account profile.

from_name

Sender Name. Not required. If not set, default Name will be used from Smaily > Account profile.

html

Link to HTML content, which needs to be in a publicly accessible URL. Required.

text

Link to plain-text content, which needs to be in a publicly accessible URL. Required.

list

List or lists of subscribers the campaign is being sent to. IDs of filters in Smaily > Subscribers. Required. See also “List user-made filters”.

due

Due date of the campaign. Value must be formatted as date-time (“YYYY-MM-DD HH:MM:SS”). If no value is set, “now” will be used with a 5-minute “grace” period, if the campaign still needs to be cancelled, which can be done in Smaily > Campaigns.


Fields “html” and “text” must be linked to existing content; but if either of them should give something else as a status HTTP/1.1 200, the query will be stopped and error “209 Could not load content from remote URL - ...” will be given as a response.


NB! If the query is posted to URL behind a secure connection (HTTPS), then it must have a valid certificate. Self-signed certificates will not work.


Example queries:


Launching a campaign - with a due date

Using scheduling and launching to several lists / filters at once.


$username = 'YOUR_USERNAME';
$password = 'YOUR_PASSWORD';
$location = 'https://<subdomain>.sendsmaily.net/api/campaign.php';
$query = array(
  'subject' => 'Head pakkumised - 8. aprill 2014',
  'from' => 'pakkumine@domeen.ee',
  'html' => 'http://domeen.ee/path/to/html/content.html',
  'text' => 'http://domeen.ee/path/to/text/content.txt',
  'list' => array(1, 2),
  'due' => '2014-04-10 07:00:00',
);

// Query ($query) should be posted as following.
// In our example it will be taken care of by “http_build_query” function.
//  subject=Head+pakkumised+-+8.+aprill+2014&from=pakkumine%40domeen.ee&html=http%3A%2F%2Fdomeen.ee%2Fpath%2Fto%2Fhtml%2Fcontent.html&text=http%3A%2F%2Fdomeen.ee%2Fpath%2Fto%2Ftext%2Fcontent.txt&list%5B0%5D=1&list%5B1%5D=2&due=2014-04-10+07%3A00%3A00

$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, http_build_query($query));
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

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

 

Result for a successful query:

 

{
  'code': 101,
  'message': 'OK'
}


See also other possible results from Possible results.


Launching a campaign - now

Launching now and to one list / filter only.


$username = 'YOUR_USERNAME';
$password = 'YOUR_PASSWORD';
$location = 'https://<subdomain>.sendsmaily.net/api/campaign.php';
$query = array(
  'subject' => 'Head pakkumised - 8. aprill 2014',
  'from' => 'pakkumine@domeen.ee',
  'from_name' => 'domeen.ee pakkumised',
  'html' => 'http://domeen.ee/path/to/html/content.html',
  'text' => 'http://domeen.ee/path/to/text/content.txt',
  'list' => 3,
);

// Query ($query) should be posted as following.
// In our example it will be taken care of by “http_build_query” function.
// subject=Head+pakkumised+-+8.+aprill+2014&from=pakkumine%40domeen.ee&from_name=domeen.ee+pakkumised&html=http%3A%2F%2Fdomeen.ee%2Fpath%2Fto%2Fhtml%2Fcontent.html&text=http%3A%2F%2Fdomeen.ee%2Fpath%2Fto%2Ftext%2Fcontent.txt&list=3

$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, http_build_query($query));
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

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


Result for a successful query:

 

{
  'code': 101,
  'message': 'OK'
}


See also other possible results from Possible results.


Launching a campaign - new, using the HTML source field

Launching now and to one list / filter only. Source of the template is provided as raw HTML.

 

$username = 'YOUR_USERNAME';
$password = 'YOUR_PASSWORD';
$location = 'https://<alamdomeen>.sendsmaily.net/api/campaign.php';
$query = array(
  'subject' => 'Head pakkumised - 8. aprill 2014',
  'from' => 'pakkumine@domeen.ee',
  'from_name' => 'domeen.ee pakkumised',
  'html_raw' => '<html><body>...</body></html>',
  'list' => 3,
);

// Postitatud andmed ($query) peaks jõudma sellisele kujule.
// Antud näites muretseb selle eest “http_build_query” funktsioon.
// subject=Cherry+pakkumised+-+8.+aprill+2014&from=pakkumine%40domeen.ee&from_name=domeen.ee+pakkumised&html_raw=%3Chtml%3E%3Cbody%3E...%3C%2Fbody%3E%3C%2Fhtml%3E&list=3

$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, http_build_query($query));
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

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


Successful results of the query are for example:

 

{
  'code': 101,
  'message': 'OK',
  'id': '1'
}

 

See also other possible results from Possible results.