Laravel Mail sending email but returning false

后端 未结 1 446
温柔的废话
温柔的废话 2020-12-15 21:14

I am trying to send a email and show any errors if needed. The following code is sending a email and I am receiving it just fine. The issue though, is that when I do the che

相关标签:
1条回答
  • 2020-12-15 21:47

    The Mail::send() method doesn't return anything.

    You can use the Mail::failures() (introduced in 4.1 I think) method to get an array of failed recipients, in your code it would look something like this.

    Mail::send('emails.users.reset', compact('user', 'code'), function($m) use ($user)
    {
        $m->to($user->email)->subject('Activate Your Account');
    });
    
    if(count(Mail::failures()) > 0){
        $errors = 'Failed to send password reset email, please try again.';
    }
    
    0 讨论(0)
提交回复
热议问题