PHPackages                             sfneal/post-office - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. sfneal/post-office

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

sfneal/post-office
==================

Email suite for Laravel applications with extended Mailable &amp; Notification functionality

2.2.0(2y ago)245.7k[3 PRs](https://github.com/sfneal/post-office/pulls)MITPHPPHP ^8.0|^8.1|^8.2|^8.3CI passing

Since Aug 19Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/sfneal/post-office)[ Packagist](https://packagist.org/packages/sfneal/post-office)[ Docs](https://github.com/sfneal/post-office)[ RSS](/packages/sfneal-post-office/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (7)Versions (26)Used By (0)

Post Office
===========

[](#post-office)

[![Packagist PHP support](https://camo.githubusercontent.com/a4c8b5651dfd82d96ba1a882ee6a7c3d6d55098ce33a2c7cc0d913ce01384095/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73666e65616c2f706f73742d6f6666696365)](https://packagist.org/packages/sfneal/post-office)[![Latest Version on Packagist](https://camo.githubusercontent.com/1737fa6a48da3a8fb2d037f2201d077274984952961f5bf1adc080e9ef55c953/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73666e65616c2f706f73742d6f66666963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfneal/post-office)[![Build Status](https://camo.githubusercontent.com/cc432d0c0a9b72fe4df189c54f2a671b00e698e00feef17962b4818f5c4fa120/68747470733a2f2f7472617669732d63692e636f6d2f73666e65616c2f706f73742d6f66666963652e7376673f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://travis-ci.com/sfneal/post-office)[![Quality Score](https://camo.githubusercontent.com/b42ece9f066e11e1efbf33772e26b8560081ece54498fd51d3d9c5183c3a7e98/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73666e65616c2f706f73742d6f66666963652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sfneal/post-office)[![Total Downloads](https://camo.githubusercontent.com/b2925cc6c539ff0f5a14e31ffaddeee70f7904acdd8d52d242fa3696bc7bbba2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73666e65616c2f706f73742d6f66666963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfneal/post-office)

Email suite for Laravel applications with extended Mailable &amp; Notification functionality

[![Post Office](https://camo.githubusercontent.com/bc15e5a96aa08aa6deab182ee0992afb692d36939854f62bac494a5e5b63f830/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f506f73744f66666963652e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d73666e65616c253246706f73742d6f6666696365267061747465726e3d636f6e6e656374696f6e73267374796c653d7374796c655f31266465736372697074696f6e3d456d61696c2b73756974652b666f722b4c61726176656c2b6170706c69636174696f6e732b776974682b657874656e6465642b4d61696c61626c652b2532362b4e6f74696669636174696f6e2b66756e6374696f6e616c697479266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313530707826696d616765733d6d61696c2d6f70656e267769647468733d6175746f)](https://camo.githubusercontent.com/bc15e5a96aa08aa6deab182ee0992afb692d36939854f62bac494a5e5b63f830/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f506f73744f66666963652e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d73666e65616c253246706f73742d6f6666696365267061747465726e3d636f6e6e656374696f6e73267374796c653d7374796c655f31266465736372697074696f6e3d456d61696c2b73756974652b666f722b4c61726176656c2b6170706c69636174696f6e732b776974682b657874656e6465642b4d61696c61626c652b2532362b4e6f74696669636174696f6e2b66756e6374696f6e616c697479266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313530707826696d616765733d6d61696c2d6f70656e267769647468733d6175746f)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require sfneal/post-office
```

To modify the post-office config file &amp; views, publish the ServiceProvider with the following command.

```
php artisan vendor:publish --provider="Sfneal\PostOffice\Providers\PostOfficeServiceProvider"
```

Usage
-----

[](#usage)

### Creating a `Mailable` &amp; sending it using the `SendMail` job.

[](#creating-a-mailable--sending-it-using-the-sendmail-job)

First create a `Mailable` extension &amp; implement applicable mailable interfaces.

```
use Sfneal\PostOffice\Mailables\Interfaces\CallToAction;
use Sfneal\PostOffice\Mailables\Interfaces\Email;
use Sfneal\PostOffice\Mailables\Interfaces\Greeting;
use Sfneal\PostOffice\Mailables\Interfaces\Message;
use Sfneal\PostOffice\Mailables\Interfaces\Title;
use Sfneal\PostOffice\Mailables\Mailable;
use Sfneal\PostOffice\Mailables\Traits\UserMailable;
use Sfneal\Users\Models\User;

class InvoiceUnpaidMailable extends Mailable implements Greeting, Email, Title, Message, CallToAction
{
    /**
     * @var User
     */
    private $user;

    /**
     * @var int
     */
    private $invoice_id;

    /**
     * InvoicePaidMailable constructor.
     *
     * @param User $user
     * @param int $invoice_id
     */
    public function __construct(User $user, int $invoice_id)
    {
        $this->user = $user;
        $this->invoice_id = $invoice_id;
        parent::__construct(
            $this->getGreeting(),
            $this->getEmail(),
            $this->getTitle(),
            $this->getMessages(),
            $this->getCallToAction()
        );
    }

    /**
     * @return string First line of email
     */
    public function getGreeting(): string
    {
        return "Hi {$this->user->first_name}";
    }

    /**
     * Email recipient.
     *
     * @return string
     */
    public function getEmail(): string
    {
        return $this->user->email;
    }

    /**
     * Retrieve the Mailable's subject/title.
     *
     * @return string
     */
    public function getTitle(): string
    {
        return "Unpaid Invoice: #{$this->invoice_id}";
    }

    /**
     * Retrieve an array of messages to include in a mailable.
     *
     * @return array
     */
    public function getMessages(): array
    {
        return [
            'You have one or more unpaid invoices.  Please send use money asap!',
            "If your invoice is not paid within 30 days we're going to send a team of ninja's to your last known location.",
        ];
    }

    /**
     * Call to Action button in the body of the email.
     *
     * @return array
     */
    public function getCallToAction(): array
    {
        return [
            'url' => 'https://google.com',
            'text' => 'Pay Invoice',
        ];
    }
}
```

Next, instantiate your `Mailable` &amp; pass it as the $mailable parameter to the `SendMail` job. `SendMail` can be dispatched to the Job queue or executed synchronously.

```
$mailable = new InvoiceUnpaidMailable($user, $invoice_id);

// Dispatch SendMail job to the queue
SendMail::dispatch($user->email, $mailable);

// Execute the SendMail synchronously
SendMail::dispatchSync($user->email, $mailable);

// Execute the SendMail synchronously without using Queueable static methods
$sent = (new SendMail($user->email, $mailable))->handle();
```

#### Creating a Notification &amp; sending it using the `Notification` facade

[](#creating-a-notification--sending-it-using-the-notification-facade)

First create a `Notification` extension that defines your notification.

```
use Sfneal\PostOffice\Notifications\Notification;
use Sfneal\Users\Models\User;

class InvoiceUnpaidNotification extends Notification
{
    /**
     * @var User
     */
    public $user;

    /**
     * @var int
     */
    public $invoice_id;

    /**
     * InvoicePaidMailable constructor.
     *
     * @param User $user
     * @param int $invoice_id
     */
    public function __construct(User $user, int $invoice_id)
    {
        $this->user = $user;
        $this->invoice_id = $invoice_id;
        parent::__construct();
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param mixed $notifiable
     * @return InvoiceUnpaidMailable
     */
    public function toMail($notifiable): InvoiceUnpaidMailable
    {
        return (new InvoiceUnpaidMailable($this->user, $this->invoice_id))->to($notifiable->email);
    }

    /**
     * Get the array representation of the notification.
     *
     * @param mixed $notifiable
     * @return array
     */
    public function toArray($notifiable): array
    {
        return [
            'user_id' => $this->user->getKey(),
            'invoice_id' => $this->invoice_id,
        ];
    }
}
```

Send the Notification using either the `send()` or `sendNow()` methods.

```
$notification = new InvoiceUnpaidNotification($user, $invoice_id);

// Send using the Job queue
$notification->send($user);

// Send synchronously
$notification->sendNow($user);
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Stephen Neal](https://github.com/sfneal)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

PHP Package Boilerplate
-----------------------

[](#php-package-boilerplate)

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance53

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Recently: every ~254 days

Total

22

Last Release

752d ago

Major Versions

0.8.0 → 1.0.02021-05-05

1.1.0 → 2.0.02024-04-15

PHP version history (8 changes)0.1.0PHP ^7.1

0.2.0PHP ^7.2

0.3.0PHP ^7.0

0.4.0PHP &gt;=7.0

0.6.0PHP &gt;=7.1

0.7.0PHP &gt;=7.4

2.0.0PHP ^7.4|^8.0|^8.1

2.1.0PHP ^8.0|^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec5fdf3b9d2183ae9c777e4aed46fd5cfd9aa4789cd05c669e5907de0b8c865c?d=identicon)[sfneal](/maintainers/sfneal)

---

Top Contributors

[![sfneal](https://avatars.githubusercontent.com/u/23200215?v=4)](https://github.com/sfneal "sfneal (135 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

sfnealpost-office

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sfneal-post-office/health.svg)

```
[![Health](https://phpackages.com/badges/sfneal-post-office/health.svg)](https://phpackages.com/packages/sfneal-post-office)
```

###  Alternatives

[spatie/laravel-failed-job-monitor

Get notified when a queued job fails

1.0k2.6M4](/packages/spatie-laravel-failed-job-monitor)[vemcogroup/laravel-sparkpost-driver

SparkPost driver to use with Laravel 6.x|7.x|8.x|9.x|10.x

421.7M1](/packages/vemcogroup-laravel-sparkpost-driver)[spatie/mailcoach

Self-host Mailcoach

4007.0k](/packages/spatie-mailcoach)[synergitech/laravel-postal

This library integrates Postal with the standard Laravel mail framework.

38107.1k](/packages/synergitech-laravel-postal)[motomedialab/smtp2go

Send emails via API using the first-class email courier SMTP2Go

1316.3k](/packages/motomedialab-smtp2go)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
