Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ardf16's avatar

NotificationFailed Event never fire

Hi, i'm using Laravel 5.6.

With basic setup for handling notification event i was able to sucessfully register NotificationSending, NotificationSent event listeners.

Exacly same way i try to setup NotificationFailed event listener but without any luck.

Not sure how the event handling works here. If the mail channel of notification fails (unable to connect with mail server) shouldn't the NotificationFailed event been fired?

0 likes
4 replies
mstrauss's avatar

Can you post some of the relevant code? Perhaps the NotificationFailed handler and implementation/usage?

ardf16's avatar

Sure but there's nothing unusial to it. I think the issue is elswhere. I'm quessing there's some issue with error handling wchich causes execution to stop wchich leads to event not being fired.

/// EventServiceProvider.php

protected $listen = [
        'App\Events\Event' => [
            'App\Listeners\EventListener',
        ],
        'App\Events\UserDeleted' => [
            'App\Listeners\UserDeleted',
        ],
        'App\Events\CommentDeleted' => [
            'App\Listeners\CommentDeleted',
        ],
        NotificationFalied::class => [
            NotificationFailedListener::class,
        ],
        NotificationSending::class => [
            NotificationSendingListener::class,
        ],
        'App\Events\NewPostCreated' => [
            'App\Listeners\CreateAdminAction'
        ],
        'App\Events\PostStatusUpdated' => [
            'App\Listeners\NotifyAdministrator'
        ]
    ];

/// NotificationFailedListener.php

<?php

namespace App\Notifications\Listeners;

use Illuminate\Notifications\Events\NotificationFailed;
use Log;

class NotificationFailedListener
{
    public function handle(NotificationFailed $event)
    {
        Log::info('------------------ NOTIFICATION FAILED ');
    }
}

When there's some issue while sending email

// error.log
Failed to authenticate on SMTP server with username "xxxxxxxxxxx" using 3 possible authenticators. Authenticator CRAM-MD5 returned Swift_TransportException: Expected response code 235 but got code "535", with message "535 5.7.0 Invalid login or password
IN ...\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php:457

and no "NotificationFalied" event fired.

mstrauss's avatar

@ardf16

Could it be the below misspelling?

current:

 NotificationFalied::class => [
            NotificationFailedListener::class,
        ],

change to:

 NotificationFailed::class => [
            NotificationFailedListener::class,
        ],
``
ardf16's avatar

That was obvious error on my part but still it's not working. Guess that's what you get working sundays :/.

Now with typos fixed and double-checked i get same thing. No event fired on NotificationFailed. Only Sending and Sent are working.

In console i get error from swift mailer. Nothing from NotificationFailed event.

Please or to participate in this conversation.