Skip to content

Instantly share code, notes, and snippets.

@mapcentia
Created August 22, 2016 20:06
Show Gist options
  • Save mapcentia/d978d186233b64086fa0e99ee9b1ec74 to your computer and use it in GitHub Desktop.
Save mapcentia/d978d186233b64086fa0e99ee9b1ec74 to your computer and use it in GitHub Desktop.
<?php
ini_set("display_errors", "On");
header("Content-type: text/plain");
require_once('/var/www/geocloud2/app/libs/vendor/autoload.php');
use Postmark\PostmarkClient;
use Postmark\Models\PostmarkException;
try {
$client = new PostmarkClient("<my token>");
} catch (PostmarkException $ex) {
// If client is able to communicate with the API in a timely fashion,
// but the message data is invalid, or there's a server error,
// a PostmarkException can be thrown.
echo $ex->httpStatusCode;
echo $ex->message;
echo $ex->postmarkApiErrorCode;
} catch (Exception $generalException) {
// A general exception is thown if the API
// was unreachable or times out.
}
$message = [
'To' => "[email protected]",
'From' => "[email protected]",
'TrackOpens' => false,
'Subject' => "Dagens høst",
'HtmlBody' => "<html><head><link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css\"></head><body>" . $mailBody . "</body></html>",
];
// $mailBody is a HTML tabek
$sendResult = $client->sendEmailBatch([$message]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment