0

This question seems too simple to be asked here I think but I'm new to Laravel and I could not find a way to get any success feedback when an email has successfully been sent. I had some successes with getting an error messages by doing this:

@if($errors->any())

<p class="feedback-error">{{ $errors->all()[0] }}</p>

@endif

PS: I want to get the message for when an email has been sent to reset their password.

get_php_workin
  • 438
  • 7
  • 14
  • maybe this answer can help you [https://stackoverflow.com/a/38906899/1873569](https://stackoverflow.com/a/38906899/1873569) – Mohammad Jul 07 '20 at 22:33
  • Does this answer your question? [Check mail is sent successfully or not on Laravel 5](https://stackoverflow.com/questions/32882357/check-mail-is-sent-successfully-or-not-on-laravel-5) – Don't Panic Jul 07 '20 at 23:09

2 Answers2

0

If you are working with a third party SMTP client then you should make a Listener to its Webhooks.

Example if you are using third party they will accept the content you gave them. They will queue it in their side. I'm using POSTMARK, when the mail bounced my application will listen for Webhook request that will send email notification or discord notification on my side that the email was bounced.

But if you are sending mail via Laravel you should do this.

try {
  Mail::to([EMAIL OF THE CLINET])->send(new SendNotifMail());
  return back()->with(['message' => 'email was successfully sent']);
} catch (Exception $e) {
  return back()->withErrors(['invalid email address']);
}

EDIT:

You can see apply this in front end like:

@if (Session::has('message'))
    {{ Session::get('message') }}
@endif
Japs
  • 977
  • 2
  • 10
  • 19
0

To get the response message for when the reset password email has been sent, there is a variable 'status' which can be listened to within the html like:

@if( Session::has('status') )
<p class="feedback-success">{{ Session::get('status') }}</p>
@endif
get_php_workin
  • 438
  • 7
  • 14