Sendy is a self-hosted email marketing tool; while hooking up a subscription form, I needed to work out what all the possible responses are to a user subscribing, depending on their current status in the Sendy database.

Version

The version documented here is 2.0.7. The previous version had a bug in it which prevented the 'Already subscribed.' status from being returned as plain text and it would always return a full HTML page. If you are using an older version, you should upgrade.

Example API call using PHP

The following example calls the subscribe API function. Replace /path/to/sendy with the full domain and path to your Sendy install, and obviously the other fields too. The 'boolean' value in the data array is set to a text value of 'true' to return the response as plain text.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '/path/to/sendy/subscribe');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
	'name' => '<name here>',
	'email' => '<email address here>',
	'list' => '<list id here>,
	'boolean' => 'true'
));
$response = curl_exec($ch);
curl_close($ch);

Possible responses, when double opt in is enabled

Note, you can also get other error messages such as 'Some fields are missing.' but these reponses assume all fields are completed and the email address is valid.