PHPackages                             makidizajnerica/laravel-multiemail - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. makidizajnerica/laravel-multiemail

ActiveLibrary[Framework](/categories/framework)

makidizajnerica/laravel-multiemail
==================================

Allow users to have more than one email address related to their account.

v1.0.0(4y ago)05MITPHPPHP &gt;=7.4

Since Nov 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/MakiDizajnerica/laravel-multiemail)[ Packagist](https://packagist.org/packages/makidizajnerica/laravel-multiemail)[ Docs](https://github.com/MakiDizajnerica/laravel-multiemail)[ RSS](/packages/makidizajnerica-laravel-multiemail/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

[![Laravel MultiEmail Logo](/art/logo.png)](/art/logo.png)

Laravel MultiEmail
==================

[](#laravel-multiemail)

Allow users to have more than one email address related to their account. Let them set their primary and recovery email addresses.

Installation
------------

[](#installation)

```
composer require makidizajnerica/laravel-multiemail
```

As for registering Service Provider, it is not necessary, Laravel will auto load provider using Package Discovery.

### Config

[](#config)

Inside `config/auth.php` add new `provider` like so:

```
'providers' => [

    // Laravel's default provider
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],

    'emails' => [
        'driver' => 'eloquent.email',
        'models' => [
            'user' => App\Models\User::class,
            'email' => MakiDizajnerica\MultiEmail\Models\Email::class,
        ],
    ],

],
```

After that you need to edit existing or create new `guard`:

```
'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'emails', //  [
    'users' => [
        'provider' => 'emails', //  'password_resets',
        'expire' => 60,
        'throttle' => 60,
    ],
],
```

The last step would be to change Laravel's default `Illuminate\Auth\Passwords\PasswordResetServiceProvider::class` inside `config/app.php` like this:

```
'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,

    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, //  \Custom\Namespace\User::class,
```

### Migrations

[](#migrations)

First you are going to need to publish migrations using command:

```
php artisan vendor:publish --tag=multiemail-migrations
```

Then run them:

```
php artisan migrate
```

After running the migrations new table `emails` will be created.

**Please don't forget to remove `email` field from `users` table!**

Usage
-----

[](#usage)

Go inside your `App\Models\User::class` and add `MakiDizajnerica\MultiEmail\HasMultipleEmails::class` trait and implement `MakiDizajnerica\MultiEmail\Contracts\HasMultipleEmails::class`:

```
namespace App\Models;

use MakiDizajnerica\MultiEmail\HasMultipleEmails;
use Illuminate\Foundation\Auth\User as Authenticatable;
use MakiDizajnerica\MultiEmail\Contracts\HasMultipleEmails as HasMultipleEmailsContract;

class User extends Authenticatable implements HasMultipleEmailsContract
{
    use HasMultipleEmails;

    //
}
```

Then be sure to define `emails()` relation method:

```
use MakiDizajnerica\MultiEmail\Models\Email;

public function emails() : HasMany
{
    return $this->hasMany(Email::class);
}
```

After that your `User::class` will have some methods available:

```
/**
 * Add new email address.
 *
 * @param  array $email
 * @param  bool $sendVerification
 * @return \MakiDizajnerica\MultiEmail\Email
 */
public function addNewEmail(array $email, $sendVerification = true);

/**
 * Find email address.
 *
 * @param  mixed $email
 * @param  string $field
 * @return \MakiDizajnerica\MultiEmail\Email|null
 */
public function findMyEmail($email, $field = 'email');

/**
 * Determine if user is the owner of the provided email address.
 *
 * @param  string $email
 * @return bool
 */
public function isMyEmail($email);

/**
 * Remove all user's email addresses.
 *
 * @return void
 */
public function removeAllEmails();

/**
 * Check if the provided email address is verified.
 *
 * @param  string $email
 * @return bool
 */
public function isVerifiedEmail($email);

/**
 * Determine if provided email address is primary.
 *
 * @param  string $email
 * @return bool
 */
public function isPrimaryEmail($email);

/**
 * Change primary email address.
 *
 * @param  string $email
 * @return void
 */
public function setEmailAsPrimary($email);

/**
 * Determine if user has recovery email address.
 *
 * @return bool
 */
public function hasRecoveryEmail();

/**
 * Determine if provided email address is recovery.
 *
 * @param  string $email
 * @return bool
 */
public function isRecoveryEmail($email);

/**
 * Change recovery email address.
 *
 * @param  string $email
 * @return void
 */
public function setEmailAsRecovery($email);
```

And some custom attributes:

```
// Get all user's verified emails
$user->verified_emails

// Get primary email
$user->email

// Get recovery email if it exists
$user->recovery_email
```

### Adding new email address

[](#adding-new-email-address)

```
use App\Models\User;

$user = User::first();

$email = $user->addNewEmail([
    'email' => 'test@mail.com'
]);
```

If user does not have primary email defined you can do something like this:

```
use App\Models\User;
use Illuminate\Support\Facades\Hash;

$user = User::create([
    'name' => 'Nick',
    'password' => Hash::make('password'),
]);

$email = $user->addNewEmail([
    'email' => 'test@mail.com',
    'type' => 'primary',
]);
```

Email verification notification will be sent every time new email is added. If you dont want to send notification you can pass second argument to the `addNewEmail()` method like so:

```
use App\Models\User;
use Illuminate\Support\Facades\Hash;

$user = User::create([
    'name' => 'Nick',
    'password' => Hash::make('password'),
]);

$email = $user->addNewEmail([
    'email' => 'test@mail.com',
    'type' => 'primary',
    'verified_at' => now(),
], false);
```

### Email types

[](#email-types)

User may only have one primary and one recovery email address, so it is recommended to use already defined methods for changing types of email addresses:

```
use App\Models\User;

$user = User::first();

if ($user->isMyEmail('test@mail.com')) {

    // Set as primary
    $user->setEmailAsPrimary('test@mail.com');

    // Set as recovery
    $user->setEmailAsRecovery('test@mail.com');

}
```

**Email address cannot be primary and recovery at the same time!**

### Password resets

[](#password-resets)

Defaut email address for password resets will be user's primary email. But if there is recovery email defined, user will be able to use that email address also. Laravel's default password reset service will still be usable as normal, to learn more about password resets visit .

Inside `multiemail.php` config file you will be able to enable/disable password resets and to specify if primary email should be used for those resets.

```
'passwords' => [
    'allow_resets' => true,
    'reset_with_primary_email' => true,
],
```

Author
------

[](#author)

**Nemanja Marijanovic** ()

Licence
-------

[](#licence)

Copyright © 2021, Nemanja Marijanovic

All rights reserved.

For the full copyright and license information, please view the LICENSE file that was distributed within the source root of this package.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1642d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7fe5cef566b020e21270218eee0e8c87e188e30bb1b9048a2f90749fe9a441ce?d=identicon)[MakiDizajnerica](/maintainers/MakiDizajnerica)

---

Tags

phpframeworklaravelauthAuthenticationemailemailsemail addressemail addresses

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/makidizajnerica-laravel-multiemail/health.svg)

```
[![Health](https://phpackages.com/badges/makidizajnerica-laravel-multiemail/health.svg)](https://phpackages.com/packages/makidizajnerica-laravel-multiemail)
```

###  Alternatives

[pestphp/pest-plugin-laravel

The Pest Laravel Plugin

22044.1M8.0k](/packages/pestphp-pest-plugin-laravel)[kompo/kompo

Laravel &amp; Vue.js FullStack Components for Rapid Application Development

11812.4k21](/packages/kompo-kompo)[jsdecena/laravel-passport-multiauth

Simple laravel passport multiple user authentication

501.1k](/packages/jsdecena-laravel-passport-multiauth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
