public createTemplate ( string $name, string $subject, string $htmlBody, string $textBody ) : Postmark\Models\DynamicResponseModel | ||
$name | string | The friendly name for this template. |
$subject | string | The template to be used for the 'subject' of emails sent using this template. |
$htmlBody | string | The template to be used for the 'htmlBody' of emails sent using this template, optional if 'textBody' is not NULL. |
$textBody | string | The template to be used for the 'textBody' of emails sent using this template, optional if 'htmlBody' is not NULL. |
return | Postmark\Models\DynamicResponseModel |
function createTemplate($name, $subject, $htmlBody, $textBody)
{
$template = array();
$template["name"] = $name;
$template["subject"] = $subject;
$template["htmlBody"] = $htmlBody;
$template["textBody"] = $textBody;
return new DynamicResponseModel($this->processRestRequest('POST', "/templates", $template));
}
function testClientCanSendMailWithTemplate() { $tk = parent::$testKeys; $client = new PostmarkClient($tk->WRITE_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT); $result = $client->createTemplate('test-php-template-' . date('c'), "{{subject}}", "Hello <b>{{name}}</b>!", "Hello {{name}}!"); $emailResult = $client->sendEmailWithTemplate($tk->WRITE_TEST_SENDER_EMAIL_ADDRESS, $tk->WRITE_TEST_EMAIL_RECIPIENT_ADDRESS, $result->templateid, array("subjectValue" => "Hello!")); $this->assertEquals(0, $emailResult->ErrorCode); }