wecreatesolutions / postmark-inbound
Convenience library for postmark inbound email parsing.
Fund package maintenance!
alexbuis
Installs: 2 573
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.1.0
Requires (Dev)
- phan/phan: ^5.3
- phpstan/phpstan: ^1.9.3
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-strict-rules: ^1.4
- phpstan/phpstan-symfony: ^1.0
- phpunit/phpunit: ^9.5
- rector/rector: ^0.15
- squizlabs/php_codesniffer: ^3.7
- wecreatesolutions/codestandards: ^2.1
README
Goal of this package is to ease the use of a Postmark Inbound Webhook.
Requirements
= PHP 8.1
Definitions
Inbound
This object allows you to convert the Postmark json string into a Message object
Contact
Represents a mail contact (cc, bcc, from, to)
Header
Represents a mail message header containing a name and value.
Attachment
Represents any attachment that was sent along with the mail message.
Examples
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.
Headers
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; }
Contacts
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; }
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.