megaads/laravel-mailservice

此包支持调用API发送邮件

v1.0.1 2018-12-24 22:33 UTC

This package is not auto-updated.

Last update: 2024-09-18 03:20:48 UTC


README

安装与配置

composer require megaads/laravel-mailservice

模块要求成功后,在config app中注册模块。

Megaads\Laravelmailservice\LaravelmailserviceServiceProvider::class

如果使用lumen,在bootstrap/app.php中注册类模块。然后向env文件添加一些配置参数

EMAIL_SERVICE_URL=
EMAIL_SERVICE_USER=
EMAIL_SERVICE_PASSWORD=

使用

在构造函数中,声明电子邮件服务。

$this->emailService = $this->app->make('sendEmailService');

创建发送邮件选项,如下所示

$options = [
    'to' => 'email1, email2, email3' // if not service using group param
    'group' => 'technical', // if not service using to params
    'content' => 'Hello World', // text string or laravel view html render
    'subject' => 'Send test email',
    'name' => 'Joe Smith',
]

最后调用服务发送邮件并等待结果。

$this->emailService->sendMail($options);