-
Notifications
You must be signed in to change notification settings - Fork 64
Sending Batches
Andrew Theken edited this page May 15, 2017
·
8 revisions
The Postmark batch API allows you to send up to 500 messages at a time. To do so, create messages that follow the same names as outlined in the Postmark developer documentation.
//Create messages that follow the JSON naming convention
//referenced above.
$message1 = ['To' => "someone@someplace.com",
'Cc' => "someoneelse@someplace.com",
'Subject' => "Message 1",
'TextBody' =>"Some plain text",
'From' => "you@yourdomain.com"];
$message2 = ['To' => "someone@someplace.com",
'Cc' => "someoneelse@someplace.com",
'Subject' => "Message 1",
'HtmlBody' =>"<b>HELLO!</b>",
'From' => "you@yourdomain.com"];
$newClient = new PostmarkClient("server_token");
//Pass the messages as an array to the `sendEmailBatch` function.
$responses = $newClient->sendEmailBatch([$message1, $message2]);
// The response from the batch API returns an array of responses for each
// message sent. You can iterate over it to get the individual results of sending.
foreach($responses as $key=>$response){
var_dump($response);
}The Postmark-PHP client can be installed from Packagist.
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.