dcorreah/postmark-inbound

处理 Postmark Inbound Webhooks 的 API。

dev-main 2024-05-27 12:12 UTC

This package is auto-updated.

Last update: 2024-09-27 12:46:22 UTC


README

Postmark Inbound

postmark-inbound

Latest Version on Packagist Software License Tests StyleCI Total Downloads

简单的 API,用于处理 Postmark Inbound Webhooks。

安装

您可以通过 composer 安装此包

composer require dcorreah/postmark-inbound

用法

$inbound = new \dcorreah\Postmark\InboundMessage(file_get_contents('php://input'));

$inbound->from->name;                   // John Doe
$inbound->from->email;                  // john@example.com
$inbound->from->full;                   // John Doe <john@example.com>

$inbound->tag;
$inbound->replyTo;
$inbound->textBody;
$inbound->htmlBody;
$inbound->messageId;                    // MessageID assigned by Postmark.
$inbound->messageIdFromHeaders;         // Message-ID value from headers.
$inbound->strippedTextReply;
$inbound->originalRecipient;

$inbound->originalDate;                 // Wed, 6 Sep 2017 12:00:00 +0200
$inbound->date;                         // PostmarkDate::class which is an extension of the DateTime::class
$inbound->date->format('Y-m-d H:i:s')   // 2017-09-06 12:00:00
$inbound->date->isUtc                   // boolean, is the date in the UTC timezone?
$inbound->date->timezone;               // +02:00
$inbound->date->inUtcTimezone()         // Sets the timezone to UTC.
$inbound->subject;                      // Subject of the message.

$inbound->isSpam;                       // boolean, is the message to be considered as spam?
$inbound->spamStatus;                   // Spam status, defaults to 'No' when not present.
$inbound->spamScore;                    // float, defaults to 0.0 when not present.

$inbound->to->count()                   // Recipient count.
$inbound->cc->count()
$inbound->bcc->count()

$inbound->attachments->count()          // Attachment count.

$inbound->headers->count()              // Header count.

收件人

$inbound->to->each(function($contact) {
    $contact->name;
    $contact->email;
    $contact->full;
    $contact->mailboxHash;
});

$inbound->cc->each(function($contact) {
    $contact->name;
    ...
});

$inbound->bcc->each(function($contact) {
    $contact->name;
    ...
});

获取第一个收件人

$inbound->to->first();

附件

$inbound->attachments->each(function($attachment) {
    $attachment->name;
    $attachment->contentType;
    $attachment->contentLength;
    $attachment->content();         // Base64 decoded data
});

获取第一个附件

$inbound->attachments->first();

获取最后一个附件

$inbound->attachments->last();

头部信息

头部信息中的 Message-ID 有时以大写 ID 为键,有时以 Id 格式。因此,如果您想从一个消息中获取 Message-ID,可以使用简单的 $inbound->messageIdFromHeaders 辅助属性。请注意,$inbound->messageId 将为您提供由 Postmark 分配的消息 ID。

$inbound->headers->each(function($value, $key) {
    ...
});

$inbound->headers->get('Message-ID');
$inbound->headers->get('MIME-Version');
$inbound->headers->get('Received-SPF');
$inbound->headers->get('X-Spam-Score');
$inbound->headers->get('X-Spam-Status');
...

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全漏洞

请查看 我们的安全策略 了解如何报告安全漏洞。

鸣谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。