PHPackages                             tihloh/prefab-messaging - 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. tihloh/prefab-messaging

ActiveLibrary

tihloh/prefab-messaging
=======================

Standalone, framework-independent external outbound messaging with mail/SMTP and pluggable delivery channels for Prefab PHP.

00PHP

Since Aug 25Pushed todayCompare

[ Source](https://github.com/tihloh/prefab-messaging)[ Packagist](https://packagist.org/packages/tihloh/prefab-messaging)[ RSS](/packages/tihloh-prefab-messaging/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Prefab Messaging
================

[](#prefab-messaging)

**Prefab Messaging** provides framework-independent **external outbound communication** for PHP applications.

> Messaging sends information outside the application. Internal bell/inbox notices belong to Prefab Notifications.

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

[](#installation)

```
composer require tihloh/prefab-messaging
```

Purpose
-------

[](#purpose)

```
Application
    ↓
Prefab Messaging
    ├── email / SMTP
    ├── SMS adapter
    ├── external push adapter
    └── custom external channel
    ↓
External recipient/provider

```

It is intentionally not an internal notification center, chat system, HTTP client, webhook framework, event bus, queue worker or scheduler.

Simple mail
-----------

[](#simple-mail)

```
$result = $messaging->mail(
    'user@example.com',
    'Annual Report',
    'Your report is ready.',
);
```

Generic channel delivery
------------------------

[](#generic-channel-delivery)

```
$result = $messaging->send(
    'sms',
    $recipient,
    new Message('OTP', 'Your code is 123456'),
);
```

`Recipient` stores channel routes such as email addresses or phone numbers. `ChannelInterface` keeps provider-specific delivery outside application business logic.

Mail
----

[](#mail)

Messaging includes a `MailChannel`, a zero-dependency `NativeMailTransport`, and a built-in `SmtpTransport` for SMTP delivery.

SMTP supports host/port configuration, authentication, STARTTLS/SSL, plain text, HTML+text MIME, CC/BCC, reply-to and attachments.

```
$smtp = new SmtpTransport([
    'host' => 'smtp.example.com',
    'port' => 587,
    'username' => 'user@example.com',
    'password' => 'secret',
    'encryption' => 'tls',
    'from' => [
        'address' => 'noreply@example.com',
        'name' => 'My System',
    ],
]);

$messaging = new MessagingManager([
    new MailChannel($smtp),
]);
```

Attachments
-----------

[](#attachments)

```
$message = new Message(
    subject: 'Report',
    text: 'Your report is attached.',
    attachments: [
        Attachment::fromPath('/tmp/report.pdf'),
    ],
);
```

Attachments can also be created from in-memory data with `Attachment::fromData()`.

Templates
---------

[](#templates)

The lightweight `Template` helper supports simple `{{variable}}` replacement without forcing a template engine.

```
$template = new Template(
    subject: 'Hello {{name}}',
    text: 'Your report {{report}} is ready.'
);

$message = $template->render([
    'name' => 'Demo User',
    'report' => 'AR-2026',
]);
```

Delivery results and hooks
--------------------------

[](#delivery-results-and-hooks)

Every delivery returns `DeliveryResult` with success/failure, channel, optional provider message ID, error and metadata.

Lifecycle hooks are available for:

```
sending
sent
failed

```

These can integrate with Prefab Logs or future Jobs without creating hard dependencies.

Relationship to Prefab Notifications
------------------------------------

[](#relationship-to-prefab-notifications)

```
External communication
Email / SMS / external push
        ↓
prefab-messaging

Internal application notice
Bell / inbox / unread state
        ↓
prefab-notifications

```

An application can use both for the same business event, but neither package requires the other.

Design philosophy
-----------------

[](#design-philosophy)

1. Standalone first.
2. Direct mail stays simple.
3. Provider-specific logic stays behind small channel/transport contracts.
4. Advanced channels are additive.
5. Internal notification storage/read state stays out of Messaging.
6. Messaging remains external outbound delivery rather than becoming a general communication framework.

The core principle is: **deliver application messages to external recipients through replaceable transports.**

###  Health Score

20

↑

LowBetter than 12% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ec00222b22ba37eb69aff9973c5303fe5773cb4c7016bf0e7aae09fe9edb232?d=identicon)[tihloh](/maintainers/tihloh)

---

Top Contributors

[![tihloh](https://avatars.githubusercontent.com/u/8960509?v=4)](https://github.com/tihloh "tihloh (28 commits)")

### Embed Badge

![Health badge](/badges/tihloh-prefab-messaging/health.svg)

```
[![Health](https://phpackages.com/badges/tihloh-prefab-messaging/health.svg)](https://phpackages.com/packages/tihloh-prefab-messaging)
```

PHPackages © 2026

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