Postmark\Models\PostmarkAttachment::fromFile PHP Метод

fromFile() публичный статический Метод

* public static function fromStream($stream, $attachmentName, $mimeType = NULL) { return new PostmarkAttachment($stream, $attachmentName, $mimeType); }
public static fromFile ( $filePath, $attachmentName, $mimeType = NULL )
    public static function fromFile($filePath, $attachmentName, $mimeType = NULL)
    {
        return new PostmarkAttachment(base64_encode(file_get_contents($filePath)), $attachmentName, $mimeType);
    }

Usage Example

 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.');
 }
All Usage Examples Of Postmark\Models\PostmarkAttachment::fromFile