sanlilin / laravel-email-templates
Laravel 电子邮件模板 (Blade)
dev-master
2023-03-17 10:05 UTC
This package is auto-updated.
Last update: 2024-09-17 13:42:27 UTC
README
Laravel (Blade) 会员和电子商务网站电子邮件模板。
与Laravel: Mailer, Language, Config完全集成,并为Laravel使用Blade模板格式。从语言系统或配置设置中设置内容选项。
易于添加到当前应用程序,无需复杂的集成步骤。三个简单的集成步骤
可用模板
- 注册欢迎信息模板
- 验证邮箱模板
- 忘记密码模板
- 付款成功模板
- 商户下单模板
- 买家下单模板
- 订单发货模板
- 需求提交模板
- 需求回复模板
- 账单/发票模板
- 提醒模板
安装使用
在应用程序上安装此库
composer require --dev sanlilin/laravel-email-templates
自动将文件和文件夹复制到您的Laravel应用程序中的相同结构。
php artisan vendor:publish --provider=Sanlilin\\EmailTemplatesServiceProvider
如果您只想复制文件的一部分,可以使用标记。
php artisan vendor:publish --tag=email-templates-config // 发布配置文件
php artisan vendor:publish --tag=email-templates-views // 发布视图文件
php artisan vendor:publish --tag=email-templates-lang // 发布多语言文件
php artisan vendor:publish --tag=email-templates-img // 发布图片文件
php artisan vendor:publish --tag=email-templates-app // 发布App文件
手动
或者,您可以自己将这些文件复制到您的Laravel应用程序中。
/config/email-template.php /resources/views/email/* /resources/lang/en/email.php /public/assets/img/email/* /app/Mail/*
使用
-
编辑
config/email-template.php
和/resources/lang/en/email.php
中的值注意: 只更改右边的值,不要更改左边的变量
-
确保您的
config/mail.php
文件已更新,以设置全局地址等。
'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 'name' => env('MAIL_FROM_NAME', 'Example'), ],
发送欢迎信息邮件
从控制器中简单地调用mailable。您还可以将一些可选变量作为数组发送。
use App\User; use App\Mail\WelcomeMember; $options = array( 'unsubscribe_url' => 'http://mysite.com/unsub', 'play_url' => 'http://google-play.com/myapp', 'ios_url' => 'http://apple-store.com/myapp', 'sendfriend_url' => 'http://mysite.com/send_friend', 'webview_url' => 'http://mysite.com/webview_url', ); $user = User:find(1); Mail::to($user)->send(new WelcomeMember($user, $options));
预览邮件
如果您想在发送电子邮件之前预览它们,请将routes/web.php
的内容复制到您的版本。记得在启动应用程序之前删除这些路由。
然后打开这些url以预览邮件模板
yourdomain.com/email_template/welcome_member
yourdomain.com/email_template/verify_email
yourdomain.com/email_template/forgot_password
yourdomain.com/email_template/thanks_payment
示例路由 routes/web.php
Route::get('email_template/welcome_member', function () { $member = App\User::find(1); return new App\Mail\WelcomeMember($member); });