Send HIPAA compliant transactional email with PHP

Send HIPAA Compliant Transactional Email with PHP - Paubox

PHP Library for the Paubox Email API

The Paubox PHP wrapper allows you to construct and send secure, HIPAA compliant messages. This package 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.

SEE ALSO: Why Healthcare Businesses Choose the Paubox Email API

Installation


Using composer:

Add Paubox to your composer.json file.

{
  "require": {
    "paubox/paubox-php": "~1"
  }
}

Getting Paubox Email 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'; $paubox = new Paubox(); $message = new PauboxMailMessage(); $content = new PauboxMailContent(); $content->setPlainText("Hello World");

$header = new PauboxMailHeader();
$header->setSubject("Testing!");
$header->setFrom("[email protected]");

$recipients = array();
array_push($recipients,'[email protected]');

$message->setHeader($header);
$message->setContent($content);
$message->setRecipients($recipients);

$sendMessageResponse = new PauboxMailSendMessageResponse();
$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'; $paubox = new Paubox(); $message = new PauboxMailMessage(); $content = new PauboxMailContent(); $content->setPlainText("Hello World");

$header = new PauboxMailHeader();
$header->setSubject("Testing!");
$header->setFrom("[email protected]");

$recipients = array();
array_push($recipients,'[email protected]');

$message->setHeader($header);
$message->setContent($content);
$message->setRecipients($recipients);
$message->setAllowNonTLS(true);

$sendMessageResponse = new PauboxMailSendMessageResponse();
$sendMessageResponse = $paubox->sendMessage($message);
print_r($sendMessageResponse);

Adding Attachments and Additional Headers

<?php require_once __DIR__ . '/vendor/autoload.php'; $paubox = new Paubox(); $message = new PauboxMailMessage(); $content = new PauboxMailContent(); $content->setPlainText("Hello World");
$content->setHtmlText("Hello World");

$header = new PauboxMailHeader();
$header->setSubject("Testing!");
$header->setFrom("[email protected]");
$header->setReplyTo("[email protected]");

$firstAttachment = new PauboxMailAttachment();
$firstAttachment->setFileName("hello_world.txt");
$firstAttachment->setContentType("text/plain");
$firstAttachment->setContent("SGVsbG8gV29ybGQhn");

$secondAttachment = new PauboxMailAttachment();
$secondAttachment->setFileName("hello_world2.txt");
$secondAttachment->setContentType("text/plain");
$secondAttachment->setContent("SGVsbG8gV29ybGQhn");

$attachments = array();
array_push($attachments,$firstAttachment);
array_push($attachments,$secondAttachment);

$recipients = array();
array_push($recipients,'[email protected]');

$bcc = array();
array_push($bcc, '[email protected]');

$message->setHeader($header);
$message->setContent($content);
$message->setAttachments($attachments);
$message->setRecipients($recipients);
$message->setBcc($bcc);

$sendMessageResponse = new PauboxMailSendMessageResponse();
$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'; $paubox = new Paubox(); $resp = $paubox->getEmailDisposition('SOURCE_TRACKING_ID');
print_r($resp);

Contributing


Bug reports and pull requests are welcome on GitHub at https://github.com/Paubox/paubox-php.

Try the Paubox Email API for FREE today.

About the author

Hoala Greevy

Founder CEO Paubox. Kayak fishing when I can.

Read more by Hoala Greevy

Get started with
end-to-end protection

Bolster your organization's security with state-of-the-art email encryption and inbound email security.

Highest rated HIPAA compliant messaging solution on G2

EmailEncryption BestMeetsRequirements MeetsRequirements
SecureEmailGateway MostImplementable Total
SecureEmailGateway Leader Leader
SecureEmailGateway EasiestToUse EaseOfUse
SecureEmailGateway EasiestAdmin EaseOfAdmin
SecureEmailGateway BestUsability Total
SecureEmailGateway BestResults Total
SecureEmailGateway BestRelationship Total
EmailEncryption UsersMostLikelyToRecommend Nps
EmailEncryption MomentumLeader Leader
SecureEmailGateway BestSupport Mid Market QualityOfSupport
EmailEncryption BestMeetsRequirements MeetsRequirements
SecureEmailGateway MostImplementable Total
SecureEmailGateway Leader Leader
SecureEmailGateway EasiestToUse EaseOfUse
SecureEmailGateway EasiestAdmin EaseOfAdmin
SecureEmailGateway BestUsability Total
SecureEmailGateway BestResults Total
SecureEmailGateway BestRelationship Total
EmailEncryption UsersMostLikelyToRecommend Nps
EmailEncryption MomentumLeader Leader
SecureEmailGateway BestSupport Mid Market QualityOfSupport