davidvandertuijn/laravel-mandrill-driver

此包已被废弃且不再维护。没有建议的替代包。

Laravel Mandrill 邮件发送器

2.0 2023-01-12 14:45 UTC

This package is auto-updated.

Last update: 2024-09-29 13:39:57 UTC


README

此包已过时,将不再维护。

Laravel Mandrill Driver

Total Downloads Latest Stable Version License

Laravel Mandrill Driver

此库为Laravel添加了Mandrill支持,并能够通过事件捕获Mandrill的响应。

安装

composer require davidvandertuijn/laravel-mandrill-driver

添加MAIL_MAILER和MANDRILL_SECRET环境变量

MAIL_MAILER=mandrill
MANDRILL_SECRET=your-api-key

将mandrill配置添加到config/services.php文件

'mandrill' => [
    'secret' => env('MANDRILL_SECRET'),
],

将mandrill选项添加到config/mail.php的"mailers"数组

'mandrill' => [
    'transport' => 'mandrill',
],

发布配置

php artisan vendor:publish --provider="Davidvandertuijn\LaravelMandrillDriver\MandrillServiceProvider"

Mandrill消息发送事件(可选)

事件应在App\Providers\EventServiceProvider.php的$listen数组中注册

use App\Listeners\Mandrill\MessageSent as MandrillMessageSentListener;
use Davidvandertuijn\LaravelMandrillDriver\app\Events\MandrillMessageSent as MandrillMessageSentEvent;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        MandrillMessageSentEvent::class => [
            MandrillMessageSentListener::class
        ],
    ];
}

在App\Listeners\Mandrill\MessageSent.php中定义监听器

namespace App\Listeners\Mandrill;

class MessageSent
{
    public function handle($event)
    {
        // Mandrill ID
        // $event->response[0]->_id
    }
}