ayoub-amzil/failed-job-notifier

A Laravel package to send email notifications on failed queued jobs.

1.0.0 2025-07-28 00:03 UTC

This package is auto-updated.

Last update: 2025-07-27 16:03:45 UTC


README

A Laravel package to send email notifications whenever a queued job fails.

Installation

composer require ayoub-amzil/failed-job-notifier

Setup

1. Publish the configuration file

php artisan vendor:publish --tag=failed-job-notifier-config

2. Configure the notification emails

Edit config/failed-job-notifier.php and add your notification recipient emails:

return [
    'notify_emails' => [
        'admin@example.com',
    ],
];

Mail Configuration

To receive email notifications on failed jobs, configure your Laravel mail settings in .env:

MAIL_MAILER= smtp / log
MAIL_HOST=you_host
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=your-email@example.com
MAIL_FROM_NAME="Your App Name"

Set mail sending to synchronous for immediate delivery:

MAIL_MAILER=smtp

But if you prefer to log emails instead of sending, set:

MAIL_MAILER=log

Emails will be saved in storage/logs/laravel.log for review. But make sure your queue worker is running if you use queued mail notifications:

php artisan queue:work

This ensures you get timely email notifications when jobs fail.

How It Works

  • Listens to Laravel's JobFailed event.
  • Sends an email notification with details about the failed job.
  • Uses Laravel’s built-in failed job handling for storage (no duplication).

Compatibility

  • Laravel 10, 11, 12+
  • PHP 8.1+

License

MIT License