public sendEmail ( string $from, string $to, string $subject, string $htmlBody = NULL, string $textBody = NULL, string $tag = NULL, boolean $trackOpens = true, string $replyTo = NULL, string $cc = NULL, string $bcc = NULL, array $headers = NULL, array $attachments = NULL, string $trackLinks = NULL ) : Postmark\Models\DynamicResponseModel | ||
$from | string | The sender of the email. (Your account must have an associated Sender Signature for the address used.) |
$to | string | The recipient of the email. |
$subject | string | The subject of the email. |
$htmlBody | string | The HTML content of the message, optional if Text Body is specified. |
$textBody | string | The text content of the message, optional if HTML Body is specified. |
$tag | string | A tag associated with this message, useful for classifying sent messages. |
$trackOpens | boolean | True if you want Postmark to track opens of HTML emails. |
$replyTo | string | Reply to email address. |
$cc | string | Carbon Copy recipients, comma-separated |
$bcc | string | Blind Carbon Copy recipients, comma-separated. |
$headers | array | Headers to be included with the sent email message. |
$attachments | array | An array of PostmarkAttachment objects. |
$trackLinks | string | Can be any of "None", "HtmlAndText", "HtmlOnly", "TextOnly" to enable link tracking. |
return | Postmark\Models\DynamicResponseModel |
function sendEmail($from, $to, $subject, $htmlBody = NULL, $textBody = NULL, $tag = NULL, $trackOpens = true, $replyTo = NULL, $cc = NULL, $bcc = NULL, $headers = NULL, $attachments = NULL, $trackLinks = NULL)
{
$body = array();
$body['From'] = $from;
$body['To'] = $to;
$body['Cc'] = $cc;
$body['Bcc'] = $bcc;
$body['Subject'] = $subject;
$body['HtmlBody'] = $htmlBody;
$body['TextBody'] = $textBody;
$body['Tag'] = $tag;
$body['ReplyTo'] = $replyTo;
$body['Headers'] = $this->fixHeaders($headers);
$body['TrackOpens'] = $trackOpens;
$body['Attachments'] = $attachments;
// Since this parameter can override a per-server setting
// we have to check whether it was actually set.
// And only include it in the API call if that is the case.
if ($trackLinks !== NULL) {
$body['TrackLinks'] = $trackLinks;
}
return new DynamicResponseModel($this->processRestRequest('POST', '/email', $body));
}
function testClientCanSendMessageWithFileSystemAttachment() { $tk = parent::$testKeys; $client = new PostmarkClient($tk->WRITE_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT); $currentTime = date("c"); $attachment = PostmarkAttachment::fromFile(dirname(__FILE__) . '/postmark-logo.png', "hello.png", "image/png"); $response = $client->sendEmail($tk->WRITE_TEST_SENDER_EMAIL_ADDRESS, $tk->WRITE_TEST_EMAIL_RECIPIENT_ADDRESS, "Hello from the PHP Postmark Client Tests! ({$currentTime})", '<b>Hi there! From <img src="cid:hello.png"/></b>', 'This is a text body for a test email.', NULL, true, NULL, NULL, NULL, array("X-Test-Header" => "Header.", 'X-Test-Header-2' => 'Test Header 2'), array($attachment)); $this->assertNotEmpty($response, 'The client could not send a message with an attachment.'); }