lacodix/laravel-scoped-mail-config
Composer 安装命令:
composer require lacodix/laravel-scoped-mail-config
包简介
A package that enables user or tenant specific mail driver configuration.
README 文档
README
This package makes it an ease to send mails with dynamic mail configuration. The mail configuration can be provided by any model or class, that implements our HasMailConfig Interface.
With this in mind it is the perfect fit for multi tenancy packages like Laravel-multitenancy by spatie.
It also offers the possibility to keep mail configs in user or team models or even if you just want to be able to offer your admin-user to set a dynamic mail configuration.
Documentation
You can find the entire documentation for this package on our documentation site
Installation
composer require lacodix/laravel-scoped-mail-config
Basic Usage
Just add our interface to your scope model
use Illuminate\Database\Eloquent\Model; use Lacodix\LaravelScopedMailConfig\Concerns\HasMailConfig; class Tenant extends Model implements HasMailConfig { public function getMailConfig($name): array { return [ 'transport' => 'smtp', 'host' => 'my.smtp.server', 'port' => 587, 'encryption' => null, 'username' => 'my@email.login', 'password' => 'mypassword', 'timeout' => 60, 'local_domain' => null, 'from' => [ 'address' => 'my@email.login', 'name' => 'myname', ], ]; } }
In your AppServiceProvider you now just need to inform the package how it shall resolve the mail configuration. By default the Package resolves the current authenticated user. So if you want to use user specific mail configuration then just skip this step.
use Lacodix\LaravelScopedMailConfig\Facades\ScopedMail;
public function register(): void
{
ScopedMail::resolveScopeUsing(fn () => Tenant::getCurrentTenant());
}
Then you can send mails with this dynamic configuration just by using our facade like laravel Mail facade:
ScopedMail::to('my@email.de')->send($mailable);
ScopedMail is just extending standard Mail facade, so there are all functionalities, that you already know from laravel Mail
Finally it is also possible to use this facade in tests
ScopedMail::fake();
Testing
composer test
Contributing
Please run the following commands and solve potential problems before committing and think about adding tests for new functionality.
composer rector:test composer insights composer csfixer:test composer phpstan:test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
lacodix/laravel-scoped-mail-config 适用场景与选型建议
lacodix/laravel-scoped-mail-config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.1k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 03 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「config」 「dynamic」 「laravel」 「tenant」 「scope」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lacodix/laravel-scoped-mail-config 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lacodix/laravel-scoped-mail-config 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lacodix/laravel-scoped-mail-config 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Flexslider slideshow content block for Silverstripe Elemental
A Zend Framework module to quickly and easily set PHP settings.
EAV modeling package for Eloquent and Laravel.
Write down your routing mapping at one place
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Mail libraries used by Zimbra Api
统计信息
- 总下载量: 2.1k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-08