wecreatesolutions/postmark-inbound

用于解析Postmark入站电子邮件的便利库。

v1.0.1 2023-01-05 15:15 UTC

This package is auto-updated.

Last update: 2024-09-05 18:51:38 UTC


README

本包的目的是简化Postmark Inbound Webhook的使用。

需求

= PHP 8.1

定义

Inbound

此对象允许您将Postmark JSON字符串转换为Message对象。

Contact

表示邮件联系人(cc,bcc,from,to)。

Header

表示包含名称和值的邮件消息头。

Attachment

表示与邮件消息一起发送的任何附件。

示例

假设我们想将Postmark入站JSON字符串转换为可以在我们的应用程序中使用的消息对象。

$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);

消息对象将包含方便的获取器,以获取表示邮件消息的所有值。

头部

可以使用getHeaders()获取所有头部,将返回一个Header对象的数组。

$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);
$headers = $message->getHeaders();
foreach ($headers as $header) {
    echo $header->name . ': ' . $header->value . PHP_EOL;
}

还可以使用一种便捷方法通过名称获取特定的头部。

$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);
$header = $message->getHeaderByName('X-Spam-Status');
if (null !== $header) {
    echo $header->name . ': ' . $header->value . PHP_EOL;
}

联系人

通过getCc()、getBcc()、getFrom()和getTo()方法,使用Contact对象来存储from、to、cc和bcc联系人。您可以通过这些方法获取Contact对象的数组。

$message = \WeCreateSolutions\PostmarkInbound\Message::fromPostmarkJson($postmarkJson);
$cc = $message->getCc();
foreach ($cc as $contact) {
    echo $contact->name . ': ' . $contact->email . PHP_EOL;
}

变更日志

有关最近更改的更多信息,请参阅变更日志

贡献

有关详细信息,请参阅贡献指南

安全漏洞

有关报告安全漏洞的详细信息,请参阅我们的安全策略

致谢

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件