gentor/laravel-elastic-email

通过 elastic email 驱动发送带附件的电子邮件的软件包

v1.3.5 2021-09-16 16:49 UTC

This package is auto-updated.

Last update: 2024-09-16 23:51:08 UTC


README

Elastic Email 的 Laravel 封装

可以发送带有多个附件的电子邮件

重要

Laravel 版本

5.5 或更早版本 - 使用版本 1.1.1

5.6 及以后版本 - 使用版本 1.3

安装

  • 步骤 1

通过 composer 安装软件包

composer require gentor/laravel-elastic-email
  • 步骤 2

将以下代码添加到 .env 文件

ELASTIC_ACCOUNT=<Add your account>
ELASTIC_KEY=<Add your key>
  • 步骤 3

在您的 .env 文件 中更新 MAIL_DRIVER 的值为 'elastic_email'

MAIL_DRIVER=elastic_email
  • 步骤 4

将以下代码添加到您的 config/services.php 文件

'elastic_email' => [
	'key' => env('ELASTIC_KEY'),
	'account' => env('ELASTIC_ACCOUNT')
]
  • 步骤 5

打开 config/app.php 文件并进入 providers 数组,然后取消 Laravel 默认的 MailServiceProvider 注释,并添加以下内容

'providers' => [
    /*
     * Laravel Framework Service Providers...
     */
    ...
//    Illuminate\Mail\MailServiceProvider::class,
    Gentor\LaravelElasticEmail\LaravelElasticEmailServiceProvider::class,
    ...
],

使用方法

此软件包的工作方式与 Laravel 的原生邮件器完全相同。请参考 Laravel 的邮件文档。

https://laravel.net.cn/docs/5.5/mail

代码示例

Mail::to($request->user())->send(new OrderShipped($order));