In my Laravel11 App with Jetstream, FOrtify and Inertia, when a cronjob runs, mails are sent via Mail:: . These Mails are sent and received without any issue which shows me the basic mail and smtp config is correct
But when I send mails via ->notify(), from the "frontend", for example for verifyEmail, the code runs without any error, but the mails get never received.
For testing purposes I first inserted a listener to MessageSending and MessageSent which showed correct format etc.
So after pretty much headbanging I switched the smtp server to a Mailtrap smtp server and there the emails appeared, also in correct format, no blacklisting, 83.4% compatibility which proves to me that everything seems fine underneath in the code.
This makes me think it could be an issue with my smtp server, which is strange because it has no issues when Mails are sent from a cronjob with Mail::. Or is it the way that notify() handles the sending below the hood (I am using Inertia),, or because I am triggering the otify from the frontend and not a php artisan command
EDIT SOLUTION: I haven't the specific answer to why it does not work, but I switched the smtp credentials to another hosting I use, and there it woorked neetly, like in mailtrap. So apart from notify doing something slightly different, the specific hosting mailserver seems to play a role too, don't know how though
The route for sending the verificationEmail is as such
Route::post('/email/verification-notification', function (Request $request) {
Log::debug('/email/verification-notification');
$request->user()->sendEmailVerificationNotification();
return back()->with('message', 'Verification link sent!');
})->middleware(['auth', 'throttle:6,1'])->name('verification.send');
and for testing purposes I overwrote the sendEmailVerificationNotification method as such, just to see if there is any issue.
public function sendEmailVerificationNotification()
{
Log::debug('User sendEmailVerificationNotification');
$this->notify(new VerifyEmail);
Log::debug('Mail sent supposedly');
}
Any idea where to look now? That it works on mailtrap seems to point me to a mailserver issue, but then again: Mail::works fine, some emails are sent...