Laravel 5 重置密码通知不会发送

Kev*_*cio 5 php email laravel

我正在尝试在我的应用程序中实现默认的重置密码通知,但是当我尝试重置密码时,没有任何反应,它只会说“我们已经通过电子邮件发送了您的密码重置链接!” 但是当我尝试检查我的邮箱时,我的应用程序没有发送电子邮件。

我对我的应用程序进行了所有必要的配置:电子邮件驱动程序、数据库设置

但是我确实更改了 Laravel 的某些部分:用户模型、用户表迁移

我确实改变了表格列。

id、姓名、US_EMAIL、密码、remember_token、created_at、updated_at、EMP_POSITION、FACTORY、CONTACT、SIGNATURE、ONLINE、DATE_ONLINE、ADMIN、LOCK

我在重置密码表上什么也没做,所有字段都从默认的 Laravel 迁移中完好无损。

当我尝试调试我的应用程序时,似乎当我尝试重置密码时,应用程序可以成功地将数据保存到“password_resets”表,但我仍然无法收到电子邮件重置通知。

我也确实关注过这个特征,我尝试“转储和死亡”以查看在我点击“发送密码重置链接”后进程的去向,并且应用程序似乎仍然可以继续这个特征,因为它仍然显示“dd”信息。

    <?php

namespace Illuminate\Auth\Passwords;

use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;

trait CanResetPassword
{
    /**
     * Get the e-mail address where password reset links are sent.
     *
     * @return string
     */
    public function getEmailForPasswordReset()
    {
        return $this->EMAIL;
    }

    /**
     * Send the password reset notification.
     *
     * @param  string  $token
     * @return void
     */
    public function sendPasswordResetNotification($token)
    {
        dd('Test SendPasswordNotification');
        $this->notify(new ResetPasswordNotification($token));
    }
}
Run Code Online (Sandbox Code Playgroud)

我也确实看过这个,但是当我尝试“转储并死”到“toMail”功能时,它没有继续。我在想也许应用程序不会发送电子邮件,因为它无法继续上课,我只是猜测,但我希望有人可以帮助我。

    <?php

namespace Illuminate\Auth\Notifications;

use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;

class ResetPassword extends Notification
{
    /**
     * The password reset token.
     *
     * @var string
     */
    public $token;

    /**
     * Create a notification instance.
     *
     * @param  string  $token
     * @return void
     */
    public function __construct($token)
    {
        $this->token = $token;
    }

    /**
     * Get the notification's channels.
     *
     * @param  mixed  $notifiable
     * @return array|string
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Build the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
      dd('Test ToMail');
        return (new MailMessage)
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', route('password.reset', $this->token))
            ->line('If you did not request a password reset, no further action is required.');
    }
}
Run Code Online (Sandbox Code Playgroud)

更新:我可以使用我的 .env 电子邮件设置发送电子邮件,我认为该应用程序可以对我使用的电子邮件服务器进行身份验证。唯一的问题是我无法收到密码重置的电子邮件通知,并且在我单击“发送密码重置链接”后也没有显示任何错误。

Kev*_*cio 5

我终于找到了问题所在。

当我将用户表中的电子邮件列更改为“US_EMAIL”时,Illuminate\Notifications trait 中有一个函数可以检索电子邮件列。

Illuminate\Notifications

  public function routeNotificationFor($driver)
{


    if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
        return $this->{$method}();
    }


    switch ($driver) {
        case 'database':
            return $this->notifications();
        case 'mail':
            return $this->email;
        case 'nexmo':
            return $this->phone_number;
    }
}
Run Code Online (Sandbox Code Playgroud)

解决方案:

on the "routeNotificationFor" function i changed this line "return $this->email;"
Run Code Online (Sandbox Code Playgroud)

到:

到“返回此->US_EMAIL;”