New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

yaquawa/laravel-email-reset

Laravel package for email reset.
2,979 2

Larablocks Analysis

yaquawa/laravel-email-reset works with Laravel 6 and 7 (latest release v1.0.8, Mar 26, 2020), all past end of life (the last on Sep 6, 2022): no more fixes, even for security.

Laravel 5 in earlier releases.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 6 and 7, past end of life since Sep 6, 2022
  • No release in the last 12 months (last: Mar 26, 2020)
  • 0 downloads a month (needs 10,000)
  • 2 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Mar 26, 2020.
  • No releases in the last 12 months.
  • First released: Jul 13, 2018.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 28, 2026.

Install
composer require yaquawa/laravel-email-reset
Latest Version:v1.0.8
PHP:>=7.1.3
Laravel:6 · 7
Older releases:5
License:MIT
Last Updated:May 2, 2020
Links: GitHub  ·  Packagist
Maintainer: yaquawa

A Laravel package for resetting user email by sending a verification link to the new email.

This package reset the user's email by:

  1. Send verification link to user's new email.
  2. If the user clicks the verification link in their new email, the package will verify the new email and set the old email to the new one.

How to install

To get started, follow the following steps.

Installation

composer require yaquawa/laravel-email-reset

Configuration

Add the following code to your <config/auth.php> file.

'defaults' => [
    'guard'       => 'web',
    'passwords'   => 'users',
    'email-reset' => 'default' // Add this line
],

// Add this entire block
'email-reset' => [
    'default' => [
        'table'  => 'email_resets',
        'expire' => 60,
        'callback' => 'App\Http\Controllers\Auth\ResetEmailController@reset',
        // 'ignore-migrations' => true,
        // 'route' => 'email/reset/{token}',
    ]
]
Migration

php artisan migrate

If you would like to use your own migration, set ignore-migrations to true in the config file (See the migration file here).

Publish the assets

The following command publishes the package's controller and translation files to your app's directories.

php artisan vendor:publish --tag=laravel-email-reset

Asset Location
Controller app/Http/Controllers/Auth/ResetEmailController.php
Translations resources/lang/vendor/laravel-email-reset
Use the CanResetEmail trait

In your app/Models/User.php file, use the CanResetEmail trait. This trait adds a resetEmail method to the user model.

namespace App\Models;

use Yaquawa\Laravel\EmailReset\CanResetEmail;

class User extends Authenticatable
{
    use CanResetEmail;
}

Usage

Send the verification email

// By calling the `resetEmail` method of `User` instance,
// an verification email will be sent to the user's new email address.
// If the user clicked the verification link, the new email address will be set.

// * The route of the verification link can be set at `route` in the config file.
 
$user->resetEmail('new_email@example.com');

If you want to change the email contents, you can do something like this in your AppServiceProvider.php.

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Notifications\Messages\MailMessage;
use Yaquawa\Laravel\EmailReset\Notifications\EmailResetNotification;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        EmailResetNotification::toMailUsing(function ($user, $token, $resetLink) {
            return (new MailMessage)
                ->line('You are receiving this email because we received a email reset request for your account.')
                ->action('Reset Email', $resetLink)
                ->line('If you did not request a email reset, no further action is required.');
        });
    }
}

After the user clicked the verification link, by default, the user will be redirected to the root of your app URL. You can change this behavior by overriding the methods of the published controller ResetEmailController.

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Yaquawa\Laravel\EmailReset\ResetEmail;

class ResetEmailController extends Controller
{
    use ResetEmail;

    /**
     * This method will be called if the token is invalid.
     * Should return a response that representing the token is invalid.
     *
     * @param $status
     *
     * @return mixed
     */
    protected function sendResetFailedResponse(string $status)
    {
        return redirect($this->redirectPathForFailure())->withErrors(['laravel-email-reset' => trans($status)]);
    }

    /**
     * This method will be called if the token is valid.
     * New email will be set for the user.
     * Should return a response that representing the email reset has succeeded.
     *
     * @param $status
     *
     * @return mixed
     */
    protected function sendResetResponse(string $status)
    {
        return redirect($this->redirectPathForSuccess())->with('laravel-email-reset', trans($status));
    }

    /**
     * The redirect path for failure.
     *
     * @return string
     */
    protected function redirectPathForFailure(): string
    {
        return '/';
    }

    /**
     * The redirect path for success.
     *
     * @return string
     */
    protected function redirectPathForSuccess(): string
    {
        return '/';
    }
    
}

Retrieve the "new email"

The new email won't be saved until the user clicks the verification link. Before user clicking the verification link you can get the new email by:

$user->new_email; // retrieve the `new_email` from database

Related Packages

madeitbelgium/laravel-email-domain-validation

PHP Laravel Email domain validator

70,496 19
altra/email

Package to manage emails

7,388 0
bronanza/laravel-emailer

This package provides abstraction for sending email

30 0
snowfire/beautymail

Send beautiful html emails with Laravel

791,590 1,313
weblee/mandrill

Laravel 5 Mandrill API Wrapper

421,363 23

Version History

Version Released PHP Laravel License
v1.0.8 >=7.1.3 ^6.0 || ^7.0 MIT
v1.0.7 >=7.1.3 ^7.0 || ^6.0 MIT
v1.0.6 >=7.1.3 ^7.0|^6.0 MIT
v1.0.5 >=7.1.3 ^7.0 MIT
v1.0.4 >=7.1.3 ~5.6 MIT