$headers = array(
'Accept: application/json',
'Content-Type: application/json',
'X-Postmark-Server-Token: ' . $this->apiKey
);
$ch = curl_init();
if (is_null($this->templateId)){
curl_setopt($ch, CURLOPT_URL, 'https://api.postmarkapp.com/email');
} else {
curl_setopt($ch, CURLOPT_URL, 'https://api.postmarkapp.com/email/withTemplate');
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$return = curl_exec($ch);
log_message('debug', 'POSTMARK JSON: ' . $encoded_data . "\nHeaders: \n\t" . implode("\n\t", $headers) . "\nReturn:\n$return");
if (curl_error($ch) != ''){
log_message('error', 'CURL ERROR: '.curl_error($ch));
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
log_message('debug', 'POSTMARK http code:' . $httpCode);
So this is the code I am using. Works fine on my local terminal.