Postmark
📬
Email delivery service integration.
# About Postmark
Postmark is a transactional email service known for its high deliverability and speed. It focuses purely on transactional email (and recently broadcast streams), ensuring your important application emails don't get stuck in queues behind marketing newsletters. Originally it was built by Wildbit and was bought bought by ActiveCampaign in 2022. fortrabbit uses Postmark.
# Booking
Head over to postmarkapp.com to sign up. You can start with a free developer account to test integration.
# Set up
Set up authentication records in your DNS. Since fortrabbit does not host your DNS, you will need to add these records at your domain registrar or DNS provider (e.g., Cloudflare, GoDaddy, AWS Route53).
Postmark requires the following:
- DKIM (DomainKeys Identified Mail): A TXT record that verifies the email was sent by a server authorized by the domain owner. Postmark will provide the specific value for this record.
- Return-Path (Custom Return-Path): A CNAME record (usually
pm-bounces.yourdomain.com) pointing topm.mtasv.net. This handles bounce processing and aligns the Return-Path domain with your From domain, which is crucial for DMARC alignment.
Once these records are added, you can verify them in the Postmark dashboard.
# Using Postmark with fortrabbit
The official PHP library for Postmark is available on Packagist as wildbit/postmark-php.
To install it in your project, run:
composer require wildbit/postmark-phpbash
# Example usage
Here is a simple example of how to send an email using the Postmark PHP library. You will need your Server Token from the Postmark dashboard.
use Postmark\PostmarkClient; // Create a client with your Server Token // Best practice: Use an environment variable $client = new PostmarkClient(getenv('POSTMARK_SERVER_TOKEN')); // Send an email: // From, To, Subject, Body $sendResult = $client->sendEmail( "sender@example.com", "receiver@example.com", "Hello from Postmark!", "This is just a friendly 'Hello' from your friends at Postmark." ); echo "Message ID: " . $sendResult->MessageID;php
There are additional abstraction plugins for CMS and frameworks.