*
public static function fromStream($stream, $attachmentName, $mimeType = NULL) {
return new PostmarkAttachment($stream, $attachmentName, $mimeType);
}
public static fromFile ( $filePath, $attachmentName, $mimeType = NULL ) |
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.'); }
<?php // Preparation require_once './vendor/autoload.php'; use Postmark\Models\PostmarkAttachment; use Postmark\PostmarkClient; //function sendBatchOfEmails(){ $attachment = PostmarkAttachment::fromFile(dirname(__FILE__) . '/test.jpg', 'attachment-file-name.jpg', image / jpg); //$TussenArray = $_POST; //$message = $_POST; $message = array('To' => "*****@*****.**", 'From' => "*****@*****.**", 'Cc' => "*****@*****.**", 'Subject' => "Test", 'TextBody' => "Dit is een testmail, ik hoop dat het nu eindelijk werkt.", 'Attachments' => $attachment); $client = new PostmarkClient("f92ee11a-3de9-48ff-801e-1b6efc9afcdf"); $sendResult = $client->sendEmailBatch($message); // Did it send successfully? if ($sendResult != null) { echo 'The email was sent!'; } else { echo 'The email could not be sent!'; } //}
header("Location: index.php"); } } } } else { } include 'attachment.php'; require_once './vendor/autoload.php'; use Postmark\PostmarkClient; use Postmark\Models\PostmarkException; use Postmark\Models\PostmarkAttachment; try { // Example request $client = new PostmarkClient("f5662a2d-8885-4cd1-b0b2-65b084216b3a"); //$_FILES[file][name][type][size] $attachment = PostmarkAttachment::fromFile($target_dir . basename($_FILES["file"]["name"]), basename($_FILES["file"]["name"]), "text/plain"); $sendResult = $client->sendEmail("*****@*****.**", $_POST['tosend'], "You Have a Request (No Reply)", "* You have a job application request from:" . "<br><br><br>" . "Name: " . $_POST['aname'] . "<br><br>" . "Age: " . $_POST['age'] . "<br><br>" . "Have Work Experience: " . $_POST['experience'] . "<br><br>" . "Experience About Previous Jobs: " . $_POST['area'] . "<br><br>" . "Contact: " . $_POST['contact'] . "<br><br>" . "Email: " . $_POST['email'] . "<br><br>" . "(Attachments is provided within the email)" . "<br><br>", "Attachement body", NULL, true, NULL, NULL, NULL, NULL, [$attachment]); } 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. } if ($sendResult) { include 'addapply.php'; header("Location: sent.php");