I'm trying to implement the default reset password notification in my Application, but when I try to do password reset, nothing happens it will just say "We have e-mailed your password reset link!" but when I try to check my mailbox no email has been sent by my applications.
I did all necessary configuration on my application: Email Driver, Database Set-up
But there are some part of the Laravel i did changed: User Model, User Table Migration
Table Columns I did changed.
id, name, US_EMAIL, password, remember_token, created_at, updated_at, EMP_POSITION, FACTORY, CONTACT, SIGNATURE, ONLINE, DATE_ONLINE, ADMIN, LOCK
I did nothing on the reset password table, all fields are intact from the default laravel migration.
While I'm trying to debug my application it seems when I try to reset my password the application can successfully save the data to "password_resets" table but again I still cannot receive email reset notification.
I also did look to this trait, i tried to "Dump and Die" to see where the process goes after I click "send password reset link" and it seems the application can still proceed to this trait because it still display the "dd" message.
<?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));
}
}
I also did look to this but when I try to "Dump and die" to the "toMail" function it did not proceed. I was thinking maybe the application won't send an email because it cannot proceed to this class, I'm just guessing but i hope there's anyone can help me to this.
<?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.');
}
}
Update: I can send email using my .env email settings, I think the application can authenticate to the email server i used. The only problem is i cannot receive email notification for the password-reset and also it does not display any error after i click "send password reset link".
I finally found where the problem is.
When i change the email column from the user table to "US_EMAIL" there is a function from the Illuminate\Notifications trait that retrieves the email column.
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;
}
}
Solution:
on the "routeNotificationFor" function i changed this line "return $this->email;"
to:
to " return this->US_EMAIL;"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With