Laravel-MailEclipse邮箱管理的使用

之前有用过这个插件,但是今天想用的时候给忘记怎么用了,搬起以前的代码复习了一下,做一个笔记分享给大家。

github

安装成功之后访问:/maileclipse

在这里插入图片描述

创建Mailables

是在代码中创建一个邮箱发送类

在这里插入图片描述

templates.json

是储存 邮箱配置信息的

class Sitefail extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */

    public $site;

    public function __construct(Site $site)
    {
        $this->site = $site;
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('网站异常通知')->view('maileclipse::templates.sitefail');
    }
}

触发的条件:

  Mail::to($site->notice_template->email)->send(new Sitefail($site));

传递site给Sitefail 类,再 渲染到 maileclipse::templates.sitefail

这边的模版是在控制台中添加

在这里插入图片描述

非常人性化的给出模版让你选择,这边有确认的,和注册的等等,方便你去使用

在这里插入图片描述

我认为最强大的还是在模版中复制,这样就免得运营人员在运营过程中有修改的需求,直接在模版中就可以修改

在这里插入图片描述

在模版中复制,是在之前邮箱类中定义的 属性 $site;

如果嵌入到laravel-admin 中使用可以使用 iframe标签

<iframe
    width="100%"
    height="1000px"
     frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"
    src="/maileclipse">
</iframe>

在这里插入图片描述

路由的/maileclipse 可以用中间件控制是否有权限查看

一个看起来很香的邮箱发送管理就这样产生了。

Laravel-MailEclipse邮箱管理的使用

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
37
粉丝
16
喜欢
132
收藏
113
排名:327
访问:2.9 万
私信
所有博文
社区赞助商