PHPackages                             sethsandaru/laravel-mail-switcher - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. sethsandaru/laravel-mail-switcher

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

sethsandaru/laravel-mail-switcher
=================================

Laravel Mail Switcher for Budget Laravel Application

1.1.0(3y ago)485395MITPHPPHP ^8.1

Since Apr 26Pushed 1y ago3 watchersCompare

[ Source](https://github.com/sethsandaru/laravel-mail-switcher)[ Packagist](https://packagist.org/packages/sethsandaru/laravel-mail-switcher)[ RSS](/packages/sethsandaru-laravel-mail-switcher/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (6)Versions (4)Used By (0)

Laravel Mail Switcher
=====================

[](#laravel-mail-switcher)

[![Build and Test](https://github.com/sethsandaru/laravel-mail-switcher/actions/workflows/build.yaml/badge.svg)](https://github.com/sethsandaru/laravel-mail-switcher/actions/workflows/build.yaml/badge.svg)[![codecov](https://camo.githubusercontent.com/3930df62060edc27004a6fdafc0586a2bf367faf39f76395bfd6b2e888871a64/68747470733a2f2f636f6465636f762e696f2f67682f7365746873616e646172752f6c61726176656c2d6d61696c2d73776974636865722f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d53314753484351423535)](https://codecov.io/gh/sethsandaru/laravel-mail-switcher)[![Latest Stable Version](https://camo.githubusercontent.com/f9a04b295b4d1e04bcaca5fb193307325a5973d1fb8bfb1c8092ad862a32b45e/68747470733a2f2f706f7365722e707567782e6f72672f7365746873616e646172752f6c61726176656c2d6d61696c2d73776974636865722f76)](//packagist.org/packages/sethsandaru/laravel-mail-switcher)

Laravel Mail Credentials Switcher is a library which helps you to:

- Manage your Mail Service Credentials
- Configure the Laravel's Mail Driver and using the available credential
- Switch to another credential if the previous one was out of usage of the current day/week/month
- Automatically reset the usage (daily/weekly/monthly) of the credentials

Use-case
--------

[](#use-case)

You have a personal Laravel Application (small or medium) or even you're a Startup. Of course, you have a **tight budget**.

So you probably can't spend much money for Email Provider Services to send out your email to your Users/Customers.

There are a lot of Email Provider Services out there that actually give you a specific amount per month (for free) to send out emails.

So, with Laravel Mail Switcher, you will have a big advantage to achieve that.

- You don't have to change `ENV` everytime one of services is running out of usage.
- You don't need to manually check to see if the email is running out.

All you need to do, is prepare the credential/information and let Laravel Mail Switcher will do that for you.

### Email Services with Free Usage

[](#email-services-with-free-usage)

- Mailgun: 5000 emails for 3-month (about 1666/month)
- Mailjet: 6000 emails per month (but 200 per day)
- Sendgrid: 100 emails per day (3000/month)
- Socketlabs: 2000/month (first month: 40000)
- Sendinblue: 300 per day (9000/month)

And many more... With Laravel Mail Switcher, you can manage the credentials and use all of them until the free usage ran out!

### Limitation

[](#limitation)

Laravel Mail Switcher is only support for `SMTP` driver at the moment.

Coming soon for others.

Requirement
-----------

[](#requirement)

- Laravel 9.x
- PHP 8.1

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

[](#installation)

```
composer require sethsandaru/laravel-mail-switcher

```

How to use?
-----------

[](#how-to-use)

Laravel Mail Switcher doesn't need a GUI to work with. We will do all the stuff in **Artisan Console**.

First, you need to run the migration:

```
php artisan migrate

```

Then, you can traverse the instructions below!!

### List All Emails

[](#list-all-emails)

```
php artisan ms:list

```

Note: You can add **--force** to show all Credentials (even the exceeded usage credentials)

### Add Email Credential

[](#add-email-credential)

```
php artisan ms:add

```

You will see some questions that need your answers in order to add. Follow the instruction!!

### Delete an Credential

[](#delete-an-credential)

```
php artisan ms:delete {credentialId}

```

### Reset Threshold of expired Credentials

[](#reset-threshold-of-expired-credentials)

```
php artisan ms:reset

```

Like, your email credential is `daily` usage and exceeded yesterday. So, today we're gonna recover it to use it again.

Cronjob Setup
-------------

[](#cronjob-setup)

By default, I will let you configure the Cron Job / Task Scheduling in your `Kernal.php`

Best practice should be daily check at 00:00

```
$schedule->command('ms:reset')->dailyAt("00:00");
```

or every minute:

```
$schedule->command('ms:reset')->everyMinute();
```

Tech Specs / QA Times
---------------------

[](#tech-specs--qa-times)

### Why did I choose to Overwrite the SMTP by listen to Mail's Events instead of ServiceProvider?

[](#why-did-i-choose-to-overwrite-the-smtp-by-listen-to-mails-events-instead-of-serviceprovider)

Because in real-life projects, not all the time, we will send out the emails. If I go with that way, then it probably costs 1 query everytime there is a connection to our application which isn't good and nice at all.

Improve this library?
---------------------

[](#improve-this-library)

Feel free to fork it and send me the PR, I'll happily review and merge it (if it's totally make sense of course).

Remember to write Unit Test also! Otherwise, I'll reject it.

Coding Style must follow PSR-1 &amp; PSR-12.

Note
----

[](#note)

After your project is growing up, making good, then, don't forget to subscribe to an Email Service Provider for long-term supports and absolutely stable in production.

Copyright
---------

[](#copyright)

2022 by Seth Phat

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

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

Every ~577 days

Total

2

Last Release

1265d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.4

1.1.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac3f098d85bb371388a3ad370678da627a3cbc53c3b107f4fd6bf46f1ce583e3?d=identicon)[sethsandaru](/maintainers/sethsandaru)

---

Top Contributors

[![sethsandaru](https://avatars.githubusercontent.com/u/23478115?v=4)](https://github.com/sethsandaru "sethsandaru (18 commits)")[![JoseVte](https://avatars.githubusercontent.com/u/3540836?v=4)](https://github.com/JoseVte "JoseVte (1 commits)")

---

Tags

laravellaravel-maillaravel-mail-driverlaravel-mail-switchermanagementlaravel-librarylaravel mail switcherlaravel switching email credentials to send out emails

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sethsandaru-laravel-mail-switcher/health.svg)

```
[![Health](https://phpackages.com/badges/sethsandaru-laravel-mail-switcher/health.svg)](https://phpackages.com/packages/sethsandaru-laravel-mail-switcher)
```

###  Alternatives

[spatie/laravel-failed-job-monitor

Get notified when a queued job fails

1.0k2.6M4](/packages/spatie-laravel-failed-job-monitor)[vemcogroup/laravel-sparkpost-driver

SparkPost driver to use with Laravel 6.x|7.x|8.x|9.x|10.x

421.7M1](/packages/vemcogroup-laravel-sparkpost-driver)[spatie/mailcoach

Self-host Mailcoach

4007.0k](/packages/spatie-mailcoach)[synergitech/laravel-postal

This library integrates Postal with the standard Laravel mail framework.

38107.1k](/packages/synergitech-laravel-postal)[motomedialab/smtp2go

Send emails via API using the first-class email courier SMTP2Go

1316.3k](/packages/motomedialab-smtp2go)

PHPackages © 2026

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