wecreatesolutions/postmark-inbound

Convenience library for postmark inbound email parsing.
21,238 13
Install
composer require wecreatesolutions/postmark-inbound
Latest Version:v1.0.2
PHP:>=8.1.0
License:MIT
Last Updated:Oct 14, 2024
Links: GitHub  ·  Packagist
Maintainer: alexbuis

Postmark Inbound Package

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.

Related Packages

jurihub/laravel-webhooks

Laravel package to handle Webhooks

1,856 7
mpociot/captainhook

Add webhooks to your Laravel app.

8,910 335
hopkins/slack-against-humanity

A slack webhook integration that lets your team play cards against humanity

173 72
hopkins/gamesbase

A base library for various games.

163 0
coconutcraig/laravel-postmark

Laravel package for sending mail via the Postmark API

3,309,603 217