highsolutions/laravel-mailer-daemon-catcher

A Laravel package for signalizing that sent e-mails couldn't be delivered

1.4.0 2020-09-09 13:13 UTC

This package is auto-updated.

Last update: 2024-03-09 21:10:57 UTC


README

License: MIT

Singalizing that sent e-mail cannot be delivered to the recipient.

Laravel-Mailer Daemon Catcher by HighSolutions

Installation

This package can be installed through Composer:

composer require highsolutions/laravel-mailer-daemon-catcher

Or by adding the following line to the require section of your Laravel webapp's composer.json file:

    "require": {
        "highsolutions/laravel-mailer-daemon-catcher": "1.*"
    }

And run composer update to install the package.

Then, if you are using Laravel <= 5.4, update config/app.php by adding an entry for the service provider:

'providers' => [
    // ...
    HighSolutions\LaravelMailderDaemonCatcher\MailerDaemonServiceProvider::class,
];

Usage

Check IMAP inbox

To check is any unseen Mailer Daemon message in the inbox, execute this command:

    php artisan mailer-daemon:catch

Package gets configuration from config/mail.php.

We recommend add this command to app/Console/Kernel.php for scheduling this task:

	$schedule->command('mailer-daemon:catch')->hourly();

Handle Mailer Daemon messages

When command finds new messages, it will fire a HighSolutions\LaravelMailderDaemonCatcher\Events\MailerDaemonMessageReceived event.

To capture this event create a listener for this event in App/Providers/EventServiceProvider.php:

	protected $listen = [
		'HighSolutions\LaravelMailderDaemonCatcher\Events\MailerDaemonMessageReceived' => [
			'App\Listeners\MailerDaemonMessageListener',
		],
	];

In that example create a listener in app/Listeners/MailerDaemonMessageListener.php e.g.:

<?php

namespace App\Listeners;

use HighSolutions\LaravelMailderDaemonCatcher\Events\MailerDaemonMessageReceived;

class MailerDaemonMessageListener
{

    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  \HighSolutions\LaravelMailderDaemonCatcher\Events\MailerDaemonMessageReceived  $event
     * @return void
     */
    public function handle(MailerDaemonMessageReceived $event)
    {
        // Access the message using $event->message...
    }
}

Testing

Run the tests with:

vendor/bin/phpunit

Changelog

1.4.0

  • Support Laravel 7.x and 8.x

1.3.0

  • Change method to withdraw the recipient and subject method
  • FIX - Error concerning connection failure catched all exceptions

1.2.0

  • Add custom config for more detailed configuration

1.1.0

  • Support Laravel 6.0

1.0.0

  • Basic version

Credits

This package is developed by HighSolutions, software house from Poland in love in Laravel.