sethsandaru/laravel-mail-switcher
Composer 安装命令:
composer require sethsandaru/laravel-mail-switcher
包简介
Laravel Mail Switcher for Budget Laravel Application
关键字:
README 文档
README
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
ENVeverytime 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 9.x
- PHP 8.1
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
2022 by Seth Phat
sethsandaru/laravel-mail-switcher 适用场景与选型建议
sethsandaru/laravel-mail-switcher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 540 次下载、GitHub Stars 达 48, 最近一次更新时间为 2021 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel library」 「laravel mail switcher」 「laravel switching email credentials to send out emails」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sethsandaru/laravel-mail-switcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sethsandaru/laravel-mail-switcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sethsandaru/laravel-mail-switcher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Inbox pattern process implementation for your Laravel Applications
Mail libraries used by Zimbra Api
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
统计信息
- 总下载量: 540
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 48
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-26