Laravel Mail Credentials switcher for Budget Laravel Applications

Overview

Laravel Mail Switcher

Build and Test codecov Latest Stable Version

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

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

  • 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

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

Coming soon for others.

Requirement

  • Laravel 8.x
  • PHP 7.4

Installation

composer require sethsandaru/laravel-mail-switcher

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

php artisan ms:list

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

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

php artisan ms:delete {credentialId}

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

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

Why did I choose to Overwrite the SMTP by listen to Mail's 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?

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 & PSR-12.

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

2021 by Seth Phat

Releases(1.0.0)
  • 1.0.0(Apr 25, 2021)

    It's available now!

    All info described in [README.md](https://github.com/sethsandaru/laravel-mail-switcher/blob/master/README.md]

    Happy coding!

    Source code(tar.gz)
    Source code(zip)
Owner
(Seth) Phat Tran
Mid-Level Full-Stack/Back-end Engineer. A Tech-nerd who loves to build awesome stuff every day with a coffee next to him.
(Seth) Phat Tran
The classic email sending library for PHP

PHPMailer – A full-featured email creation and transfer class for PHP Features Probably the world's most popular code for sending email from PHP! Used

PHPMailer 16.8k Jun 13, 2021
Bounce Mail Handler for PHP | This is a "reboot" of PHPMailer-BMH from WorxWare.

PHP 7.0+ Support Composer & PSR-0 Support PHPUnit testing via Travis CI (TODO: more tests needed) PHP-Quality testing via SensioLabsInsight (TODO: mor

Lars Moelleken 38 Jun 8, 2021
Send email across all platforms using one interface

Send email across all platforms using one interface. Table Of Content Requirements Installation Providers AmazonSES Mailgun Mailjet Mandrill Postmark

Omnimail 326 Jun 20, 2021
Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)

PHP IMAP Initially released in December 2012, the PHP IMAP Mailbox is a powerful and open source library to connect to a mailbox by POP3, IMAP and NNT

Sergey 1.3k Jun 14, 2021
:envelope: E-Mail Address Validator (syntax, dns, trash, typo)

✉️ E-Mail Address Validator for PHP Warning The best way to validate an e-mail address is still to send a duplicate opt-in-mail, when the user clicks

Lars Moelleken 32 Mar 3, 2021
This module is the core of phpList 4

phpList core module About phpList phpList is an open source newsletter manager. This project is a rewrite of the original phpList. About this package

phpList 79 May 4, 2021
Mail sending module for Mezzio and Laminas MVC with support for file attachment and template email composition

This module provides an easy and flexible way to send emails from Mezzio and Laminas MVC applications (formerly known as Zend Expressive and Zend MVC). It allows you to pre-configure emails and transports, and then send those emails at runtime.

null 81 Feb 16, 2021
CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very usefull when you're sending emails.

CssToInlineStyles class Installation CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline style

Tijs Verkoyen 5.4k Jun 10, 2021
The Mailer component helps sending emails

Mailer Component The Mailer component helps sending emails. Getting Started $ composer require symfony/mailer use Symfony\Component\Mailer\Transport;

Symfony 679 Jun 17, 2021