Postal
A modern email library for CodeIgniter 4.
Write a message once and send it through SMTP, Amazon SES, Resend, sendmail or a failover chain. You choose the provider in config, not code. Existing service('email') calls keep working, so you can adopt Postal one step at a time.
Requires PHP 8.2+ and CodeIgniter 4.7+. See Installation for extensions and configuration.
See it in action
<?php
namespace App\Mails;
use Myth\Postal\Mailable;
class Welcome extends Mailable
{
public function __construct(private readonly string $address)
{
parent::__construct();
}
protected function build(): void
{
$this->from('hello@example.com', 'Acme')
->to($this->address)
->subject('Welcome aboard')
->markdown('emails/welcome');
}
}
$result = (new Welcome('user@example.com'))->send();
Either way, send() returns a SendResult instead of a bare bool:
Out of the box Postal's default mailer discards every message, so nothing is sent by accident. The Quick Start sets up a mailer in a few lines.
Why Postal
-
Deliver anywhere
SMTP, sendmail, Amazon SES and Resend, with failover between them and DKIM signing. Or write your own transport.
-
Write mail as classes
Mailables keep each email in one class, written in HTML or Markdown with a shared layout, and previewed in the browser.
-
Send safely
A suppression list filters recipients and
List-Unsubscribeheaders are added for you. Events let you change or stop any send. -
Test without sending
Mailer::fake()records every message so your tests can assert on it, with no network access.
Where to go next
-
New to Postal?
Install, configure a mailer and send your first Mailable in the Quick Start.
-
Already using CI4's
Email?
Move over in stages, without rewriting your app, with Migrating from CI4's Email.
-
Looking something up?
Every method and setting is in the reference: Email, SendResult and Config\Mailer.
-
Want the big picture?
How Postal Works explains mailers, transports and what happens during a send.
Support Postal
Postal is free and open source, built and maintained by Lonnie Ezell. If it saves you time, please consider sponsoring its development on GitHub. Sponsorship helps fund new features, fixes and these docs.