Goal of this package is to ease the use of a Postmark Inbound Webhook.
= PHP 8.1
This object allows you to convert the Postmark json string into a Message object
Represents a mail contact (cc, bcc, from, to)
Represents a mail message header containing a name and value.
Represents any attachment that was sent along with the mail message.
Let's say we want to convert the Postmark inbound json string into a message object that we can use in our application.
$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);
The message object will contain convenient getters to all values that represent the mail message.
All headers can be fetched with getHeaders(), an array of Header objects will be returned.
$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);
$headers = $message->getHeaders();
foreach ($headers as $header) {
echo $header->name . ': ' . $header->value . PHP_EOL;
}
A convenience method is also available to get a specific header by name.
$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);
$header = $message->getHeaderByName('X-Spam-Status');
if (null !== $header) {
echo $header->name . ': ' . $header->value . PHP_EOL;
}
The Contact object is used to store from, to, cc and bcc contacts. Via the getCc(), getBcc(), getFrom() and getTo() methods you are able to get an array of Contact objects.
$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);
$cc = $message->getCc();
foreach ($cc as $contact) {
echo $contact->name . ': ' . $contact->email . PHP_EOL;
}
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.