PHPackages                             kiwilan/php-notifier - 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. kiwilan/php-notifier

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

kiwilan/php-notifier
====================

PHP Notifier is a package to send mails or notifications for Discord or Slack.

0.0.40(2y ago)11.7k[6 PRs](https://github.com/kiwilan/php-notifier/pulls)1MITPHPPHP ^8.1CI passing

Since Feb 9Pushed 1mo agoCompare

[ Source](https://github.com/kiwilan/php-notifier)[ Packagist](https://packagist.org/packages/kiwilan/php-notifier)[ Docs](https://github.com/kiwilan/php-notifier)[ GitHub Sponsors](https://github.com/kiwilan)[ RSS](/packages/kiwilan-php-notifier/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (21)Used By (1)

**PHP Notifier**
================

[](#php-notifier)

[![Banner with british letter box picture in background and Notifier title](https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg)](https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg)

[![php](https://camo.githubusercontent.com/731af46a12737ef77d62979aae24e91e42c2d5dcad6b2ef112eb0cd421851955/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f7374796c653d666c61742d737175617265266c6162656c3d504850266d6573736167653d76382e3126636f6c6f723d373737424234266c6f676f3d706870266c6f676f436f6c6f723d666666666666266c6162656c436f6c6f723d313831383162)](https://www.php.net/)[![version](https://camo.githubusercontent.com/d32304036a8b5f0470f8cc1485e8fb5310714dd01e9a8ca67591e0d48ba31ecc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6977696c616e2f7068702d6e6f7469666965722e7376673f7374796c653d666c61742d73717561726526636f6c6f72413d31383138314226636f6c6f72423d373737424234)](https://packagist.org/packages/kiwilan/php-notifier)[![downloads](https://camo.githubusercontent.com/fc2cbf9055384cfe77b3a7536fc853f214d6c94fe3411a27a286869bd2985d4d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6977696c616e2f7068702d6e6f7469666965722e7376673f7374796c653d666c61742d73717561726526636f6c6f72413d31383138314226636f6c6f72423d373737424234)](https://packagist.org/packages/kiwilan/php-notifier)[![license](https://camo.githubusercontent.com/f0da83a040b3832607c3ab86d206d2f108e9231711a50ce57201514dce0b4961/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6977696c616e2f7068702d6e6f7469666965722e7376673f7374796c653d666c61742d73717561726526636f6c6f72413d31383138314226636f6c6f72423d373737424234)](https://github.com/kiwilan/php-notifier/blob/main/README.md)[![tests](https://camo.githubusercontent.com/a9cccdf5346797aed7c79299a60a7c6bb6bc110bbef05c1c4107e3cccdb62f9e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b6977696c616e2f7068702d6e6f7469666965722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d73717561726526636f6c6f72413d313831383142)](https://github.com/kiwilan/php-notifier/actions/workflows/run-tests.yml)[![codecov](https://camo.githubusercontent.com/07b8834686bb43a18e7dcf86f666546ffe5896d8ad63f5a9fd3ee131dc3e6838/68747470733a2f2f636f6465636f762e696f2f67682f6b6977696c616e2f7068702d6e6f7469666965722f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d6e383570304f6f427530)](https://codecov.io/gh/kiwilan/php-notifier)

PHP Notifier is a package to send mails or notifications for Discord or Slack.

Important

This package does not support push notifications or SMS (if you interested, a PR is welcome).

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

[](#installation)

You can install the package via composer:

```
composer require kiwilan/php-notifier
```

Note

For Laravel, you can use [`kiwilan/notifier-laravel`](https://github.com/kiwilan/notifier-laravel) package.

Usage
-----

[](#usage)

This package offer a support for Discord and Slack webhooks, and emails with `symfony/mailer`.

- [Discord](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks): support message and rich embeds webhooks.
- [Slack](https://api.slack.com/messaging/webhooks): support message and attachments webhooks (without legacy API support).
- Mail: support message and attachments with [`symfony/mailer`](https://symfony.com/doc/current/mailer.html).

### Discord

[](#discord)

You can send simple message, with user and avatar. Default user and avatar will be webhook's name and avatar.

```
use Kiwilan\Notifier\Notifier;

$notifier = new Notifier();
$discord = $notifier->discord('https://discord.com/api/webhooks/1234567890/ABCDEFGHIJKLMN0123456789')
    ->message('Hello, Discord!')
    ->user('Notifier', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->send();
```

You can also send rich embeds.

[![discord-rich-embed](./docs/discord-rich-embed.jpg)](./docs/discord-rich-embed.jpg)

```
use Kiwilan\Notifier\Notifier;

$notifier = new Notifier();
$discord = $notifier->discord($webhook)
    ->rich('Rich advanced')
    ->title('Notifier')
    ->user('Notifier', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->url('https://ewilan-riviere.com')
    ->author('Author', 'https://ewilan-riviere.com', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->color('#3498db')
    ->timestamp()
    ->fields([
        ['name' => 'Field 1', 'value' => 'Value 1'],
        ['name' => 'Field 2', 'value' => 'Value 2'],
    ], inline: true)
    ->thumbnail('https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->image('https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->footer('Footer', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->send();
```

### Mail

[](#mail)

Mail use `symfony/mailer` to send emails.

```
use Kiwilan\Notifier\Notifier;

$notifier = new Notifier();
$mailConfig = $notifier->mail('smtp')
    ->mailer('smtp')
    ->host('mailpit')
    ->port(1025)
    ->username(null)
    ->password(null)
    ->encryption('tls');
```

```
$mailConfig->from('hello@example.com', 'Hello')
    ->to('to@example.com', 'To')
    ->subject('Hello, Mail!')
    ->message('Hello, Mail!')
    ->html('Hello, Mail!')
    ->send();
```

Note

If `html` is not set, `message` will be used as HTML content. And if `html` is set but not `message`, `html` will be used as plain text content with `strip_tags` method.

Multiple recipients can be added with `to` method.

```
use Symfony\Component\Mime\Address;

$mailConfig->from('hello@example.com', 'Hello')
    ->to([
      new Address('to1@example.com', 'To1'),
      new Address('to2@example.com', 'To2'),
    ])
    ->send();
```

You can add attachments with `addAttachment` method.

```
$mailConfig->addAttachment('path/to/file.txt', 'file.txt')
    ->send();
```

### Slack

[](#slack)

You can send simple message.

```
use Kiwilan\Notifier\Notifier;

$notifier = new Notifier();
$slack = $notifier->slack('https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX')
    ->message('Hello, Slack!')
    ->send();
```

You can also send attachments.

```
use Kiwilan\Notifier\Notifier;

$notifier = new Notifier();
$slack = $notifier->slack($webhook)
    ->attachment('*Hello, Slack!*')
    ->color('#36a64f')
    ->pretext('Optional pre-text that appears above the attachment block')
    ->author('Kiwilan', 'https://github.com/kiwilan')
    ->title('php-notifier', 'https://github.com/kiwilan/php-notifier')
    ->text('Optional text that appears within the attachment')
    ->fields([
        [
            'title' => 'Priority',
            'value' => 'High',
            'short' => false,
        ],
        [
            'title' => 'Priority',
            'value' => 'High',
            'short' => false,
        ],
    ])
    ->imageUrl('https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->footer('Slack API', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')
    ->timestamp(new DateTime())
    ->send();
```

### HTTP

[](#http)

You can use `http` method to send HTTP request.

```
use Kiwilan\Notifier\Notifier;

$notifier = new Notifier();
$http = $notifier->http('https://jsonplaceholder.typicode.com/posts')
    ->method('POST')
    ->send();

$statusCode = $http->getStatusCode();
$body = $http->getResponseBody();
$headers = $http->getResponseHeaders();
```

### Client

[](#client)

HTTP requests use native stream context to send data, `curl` and `guzzle` can be used as option (default is `stream`).

Warning

If you use `guzzle`, you need to install `guzzlehttp/guzzle` package.

```
use Kiwilan\Notifier\Notifier;

$notifier = new Notifier();

$stream = $notifier->client('stream') // default
    ->discord($webhook)
    ->message('Hello, Discord!')
    ->send();

$curl = $notifier->client('curl') // use curl instead of stream
    ->discord($webhook)
    ->message('Hello, Discord!')
    ->send();

$guzzle = $notifier->client('guzzle') // use guzzle instead of stream (need guzzlehttp/guzzle package)
    ->discord($webhook)
    ->message('Hello, Discord!')
    ->send();
```

To know if request is successful, you can use `isSuccess` method.

```
$notifier = new Notifier();

$discord = $notifier->discord($webhook)
    ->message('Hello, Discord!')
    ->send();

if ($discord->isSuccess()) {
    echo 'Message sent!';
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ewilan Rivière](https://github.com/ewilan-riviere)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

[![](https://user-images.githubusercontent.com/48261459/201463225-0a5a084e-df15-4b11-b1d2-40fafd3555cf.svg)](https://github.com/kiwilan)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance61

Regular maintenance activity

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.2% 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 ~7 days

Recently: every ~19 days

Total

13

Last Release

737d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/58eb34eac9af07c3352e83060e472e1c280838ebe0568692561c00a2cfde9e57?d=identicon)[ewilan-riviere](/maintainers/ewilan-riviere)

---

Top Contributors

[![ewilan-riviere](https://avatars.githubusercontent.com/u/48261459?v=4)](https://github.com/ewilan-riviere "ewilan-riviere (80 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

discordmailnotificationnotifierslackwebhookmailnotifierslackdiscord

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kiwilan-php-notifier/health.svg)

```
[![Health](https://phpackages.com/badges/kiwilan-php-notifier/health.svg)](https://phpackages.com/packages/kiwilan-php-notifier)
```

###  Alternatives

[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[symfony/slack-notifier

Symfony Slack Notifier Bridge

426.1M11](/packages/symfony-slack-notifier)[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14642.7k1](/packages/guanguans-laravel-exception-notify)[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)[symfony/discord-notifier

Symfony Discord Notifier Bridge

37387.7k2](/packages/symfony-discord-notifier)[dotkernel/dot-mail

Dotkernel mail component based on symfony mailer

1140.0k5](/packages/dotkernel-dot-mail)

PHPackages © 2026

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