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. |
from_name | Sender Name. Not required. |
html | Link to HTML 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. |
tags | Array of tag or tags. Optional. |
Field “html” must be linked to existing content; if URL should respond with other status code than 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.
Plain-text content will be generated from HTML content.
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.
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', '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&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.