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

DhPandya's avatar

Retrieve Mailgun message-id from Laravel notifications

Hello there,

I'm working on a task where the client wants to check whether the Notification(Email) is delivered to the recipient or not. I'm using mailgun SMTP details and also configured the webhook from mailgun.

Now I need only the message-id from the Laravel notifications so I can cross-verify it with the response I receive from the Mailgun webhook.

Can you please help with that?

Thanks

0 likes
3 replies
elton869's avatar

Using Laravel Notification I never needed to get the message-id, but using an event I needed, maybe the code can help you:

<?php

namespace App\Listeners;

use Illuminate\Mail\Events\MessageSent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class EmailMensagemEnviada
{
    /**
     * Handle the event.
     *
     * @param  MessageSent  $event
     * @return void
     */
    public function handle(MessageSent $event)
    {
			//message-id
    		$event->message->getId();
    }
}
DhPandya's avatar

@elton869 Thanks for your reply, But as I described above I am sending emails using Laravel notifications and also established a webhook for Mailgun. So, I want to track whether the email has been delivered or not. So to do cross-verification I need a message-id that has been returned from the Mailgun. (or something using which I can match).

Please or to participate in this conversation.