omarpre/paubox
Composer 安装命令:
composer require omarpre/paubox
包简介
A PHP package for the Paubox Transactional Email API (Fork of original paubox-php SDK)
README 文档
README
This is fork of Paubox php SDK, to make it compatible with Laravel version 9
Paubox PHP
This is the official PHP wrapper for the Paubox Email API.
The Paubox Email API allows your application to send secure, HIPAA compliant email via Paubox and track deliveries and opens. The API wrapper also allows you to construct and send messages.
Table of Contents
Installation
Using composer:
$ composer require omarpre/paubox
Getting Paubox API Credentials
You will need to have a Paubox account. You can sign up here.
Once you have an account, follow the instructions on the Rest API dashboard to verify domain ownership and generate API credentials.
Configuring API Credentials
Include your API credentials in your environment file.
$ echo "export PAUBOX_API_KEY='YOUR_API_KEY'" > .env $ echo "export PAUBOX_API_USER='YOUR_ENDPOINT_NAME'" >> .env $ source .env $ echo ".env" >> .gitignore
Usage
To send email, prepare a Message object and call the sendMessage method of Paubox.
Sending messages
<?php require_once __DIR__ . '/vendor/autoload.php'; $dotenv = Dotenv\Dotenv::create(__DIR__); $dotenv->load(); $paubox = new Paubox\Paubox(); $message = new Paubox\Mail\Message(); $content = new Paubox\Mail\Content(); $content->setPlainText("Hello World"); $header = new Paubox\Mail\Header(); $header->setSubject("Testing!"); $header->setFrom("sender@domain.com"); $recipients = array(); array_push($recipients,'recipient@example.com'); $message->setHeader($header); $message->setContent($content); $message->setRecipients($recipients); $sendMessageResponse = new Paubox\Mail\SendMessageResponse(); $sendMessageResponse = $paubox->sendMessage($message); print_r($sendMessageResponse);
Allowing non-TLS message delivery
If you want to send non-PHI mail that does not need to be HIPAA-compliant, you can allow the message delivery to take place even if a TLS connection is unavailable.
This means the message will not be converted into a secure portal message when a non-TLS connection is encountered. To allow a non-TLS message delivery, call the setAllowNonTLS(true) method on the message object.
<?php require_once __DIR__ . '/vendor/autoload.php'; $dotenv = Dotenv\Dotenv::create(__DIR__); $dotenv->load(); $paubox = new Paubox\Paubox(); $message = new Paubox\Mail\Message(); $content = new Paubox\Mail\Content(); $content->setPlainText("Hello World"); $header = new Paubox\Mail\Header(); $header->setSubject("Testing!"); $header->setFrom("sender@domain.com"); $recipients = array(); array_push($recipients,'recipient@example.com'); $message->setHeader($header); $message->setContent($content); $message->setRecipients($recipients); $message->setAllowNonTLS(true); $sendMessageResponse = new Paubox\Mail\SendMessageResponse(); $sendMessageResponse = $paubox->sendMessage($message); print_r($sendMessageResponse);
Forcing Secure Notifications
Paubox Secure Notifications allow an extra layer of security, especially when coupled with an organization's requirement for message recipients to use 2-factor authentication to read messages (this setting is available to org administrators in the Paubox Admin Panel).
Instead of receiving an email with the message contents, the recipient will receive a notification email that they have a new message in Paubox.
<?php require_once __DIR__ . '/vendor/autoload.php'; $dotenv = Dotenv\Dotenv::create(__DIR__); $dotenv->load(); $paubox = new Paubox\Paubox(); $message = new Paubox\Mail\Message(); $content = new Paubox\Mail\Content(); $content->setPlainText("Hello World"); $header = new Paubox\Mail\Header(); $header->setSubject("Testing!"); $header->setFrom("sender@domain.com"); $recipients = array(); array_push($recipients,'recipient@example.com'); $message->setHeader($header); $message->setContent($content); $message->setRecipients($recipients); $message->setForceSecureNotification("true"); $sendMessageResponse = new Paubox\Mail\SendMessageResponse(); $sendMessageResponse = $paubox->sendMessage($message); print_r($sendMessageResponse);
Adding Attachments and Additional Headers
<?php require_once __DIR__ . '/vendor/autoload.php'; $dotenv = Dotenv\Dotenv::create(__DIR__); $dotenv->load(); $paubox = new Paubox\Paubox(); $message = new Paubox\Mail\Message(); $content = new Paubox\Mail\Content(); $content->setPlainText("Hello World"); $content->setHtmlText("<html><head></head><body>Hello World</body></html>"); $header = new Paubox\Mail\Header(); $header->setSubject("Testing!"); $header->setFrom("sender@domain.com"); $header->setReplyTo("reply_to@domain.com"); $firstAttachment = new Paubox\Mail\Attachment(); $firstAttachment->setFileName("hello_world.txt"); $firstAttachment->setContentType("text/plain"); $firstAttachment->setContent("SGVsbG8gV29ybGQh\n"); $secondAttachment = new Paubox\Mail\Attachment(); $secondAttachment->setFileName("hello_world2.txt"); $secondAttachment->setContentType("text/plain"); $secondAttachment->setContent("SGVsbG8gV29ybGQh\n"); $attachments = array(); array_push($attachments,$firstAttachment); array_push($attachments,$secondAttachment); $recipients = array(); array_push($recipients,'recipient@example.com'); $bcc = array(); array_push($bcc, 'recipient2@example.com'); $cc = array(); array_push($cc, 'recipientcc@example.com'); $message->setHeader($header); $message->setContent($content); $message->setAttachments($attachments); $message->setRecipients($recipients); $message->setBcc($bcc); $sendMessageResponse = new Paubox\Mail\SendMessageResponse(); $sendMessageResponse = $paubox->sendMessage($message); print_r($sendMessageResponse);
Checking Email Dispositions
The SOURCE_TRACKING_ID of a message is returned in the response of the sendMessage method. To check the status for any email, use its source tracking id and call the getEmailDisposition method of Paubox:
<?php require_once __DIR__ . '/vendor/autoload.php'; $dotenv = Dotenv\Dotenv::create(__DIR__); $dotenv->load(); $paubox = new Paubox\Paubox(); $resp = $paubox->getEmailDisposition('SOURCE_TRACKING_ID'); print_r($resp);
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/omarpre/paubox.
License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright
Copyright © 2021, Paubox, Inc.
omarpre/paubox 适用场景与选型建议
omarpre/paubox 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.53k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 omarpre/paubox 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 omarpre/paubox 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-04-25