buibr / laramic-mailer
本包最新版本(v0.1)的许可信息不可用。
当您需要动态邮件,多个邮件服务器
v0.1
2024-09-09 16:21 UTC
Requires
- php: ^8.2
- laravel/framework: ^8.0
- nrb/laravel-helpers: *
README
Laramic Mailer 是一个 Laravel 插件,允许基于数据库存储的设置动态配置电子邮件。此包使得管理多个邮件配置并在不将电子邮件设置硬编码到 .env 文件中时发送电子邮件变得简单。
特性
- 动态邮件配置:从数据库获取邮件设置并在飞行中应用它们。
- 无缝集成:轻松集成 Laravel 的原生邮件功能。
- 多邮件支持:支持多种不同用例的邮件。
- 灵活配置:在数据库中定义自己的邮件配置,包括 SMTP 主机、端口、加密等。
- 可配置的发送者信息:为每封邮件动态配置“发件人”名称和地址。
- 可扩展性:自定义邮件配置的存储和检索方式。
安装
步骤 1:通过 Composer 安装
要安装此包,请运行以下命令
composer require buibr/laramic-mailer
步骤 2:发布配置和迁移
安装后,发布配置和迁移文件
php artisan vendor:publish --tag=laramic-mailer-config php artisan migrate
用法
直接在数据库中添加您的邮件配置(SMTP 主机、端口、加密等)。当发送电子邮件时,插件将从数据库中获取必要的邮件配置并在飞行中应用它。您可以定义和管理多个邮件,所有这些都存储在数据库中。
使用 Dynami MailServer 服务器和 laramic 与默认 Laravel 功能的示例
// from Mail::to($request->user())->send(new OrderShipped($order)); // to Laramic::use($ticketCommunication->mailServer) ->to($request->user()) ->send(new InvoiceEmail(Invoice $invoice));
所有其他 Laravel Mail 或 MailManager 方法都可以作为 Laramic 的父层正常使用。请参阅:https://laravel.net.cn/docs/11.x/mail
测试
<?php use Laramic\Mailers\Facades\Laramic; use Laramic\Mailers\Models\Laramic; // Call this method to send test email to authenticated user Laramic::testMail(MailServer $mailServer); // Call this method to ping the email server, if configuration is wrong, then the ping will fail. Laramic::ping(MailServer $mailServer);