globalsprojects/nova-custom-email-sender

这是一个用于 Laravel Nova 管理面板的工具,允许您发送自定义电子邮件消息,这些消息利用了应用程序现有的设置和配置。

v1.0.2 2019-03-29 20:04 UTC

This package is auto-updated.

Last update: 2024-09-07 02:56:55 UTC


README

‼️ 这是一个从以下中派生的。

功能

  • 继承 Laravel 应用程序的任何修改和自定义的 Blade 通知布局。
    • 现有的电子邮件模板可以发布到 views/vendor 目录
    • 允许您提供自定义的 Blade 模板(应用适当的变量)
  • 目前提供两种发送消息的方法
    • 简单切换以将消息发送给所有用户
    • 通过临时的电子邮件输入和电子邮件地址验证
  • 利用 Quill WYSIWYG 编辑器,并能够自定义用户可用的按钮/功能
  • 语言本地化
  • 在发送之前预览消息
  • 各种设置以调整此工具以适应您的安装。

安装

您可以通过 composer 安装此包

composer require globalsprojects/custom-email-sender

然后您需要将包的配置和 blade 视图文件发布到您的应用程序安装中

php artisan vendor:publish --provider="GlobalsProjects\CustomEmailSender\ToolServiceProvider"

如果您只想发布部分供应商资产,可以使用以下标签

  • config
  • views
  • lang

使用必要的 artisan 命令,如下所示

php artisan vendor:publish --provider="GlobalsProjects\CustomEmailSender\ToolServiceProvider" --tag=config

App\Providers\NovaServiceProvider 中更新 tools 函数。这将包括侧边栏上的链接。

    public function tools()
    {
        return [new CustomEmailSender()];
    }

配置

以下配置项可以在 novaemailsender.php 配置文件中找到。

示例

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Mail Driver
    |--------------------------------------------------------------------------
    |
    | The mail driver with which the message will be sent with.
    |
    */

    'provider' => config('mail.driver'),

    /*
    |--------------------------------------------------------------------------
    | Priority
    |--------------------------------------------------------------------------
    |
    | The priority in which the emails sent will be added to the queue driver.
    | In order to take advantage of this feature, you must specify queue
    | priority in your worker like so: php artisan queue:work --queue=high,low
    |
    */

    'priority' => 'low',

    /*
    |--------------------------------------------------------------------------
    | Mail Driver
    |--------------------------------------------------------------------------
    |
    | The name and associated email address from which the message will be sent.
    |
    */

    'from' => [
        'address' => config('mail.from.address'),
        'name' => config('mail.from.name'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Default User Model
    |--------------------------------------------------------------------------
    |
    | To use the "send all" feature, define the model class and the accompanying
    | properties to populate the message with.
    |
    */

    'model' => [
        'class' => \App\User::class,
        'email' => 'email',
        'name' => null,
        'first_name' => 'first_name',
        'last_name' => 'last_name',
    ],

    /*
    |--------------------------------------------------------------------------
    | Email Template
    |--------------------------------------------------------------------------
    |
    | The Blade template used to send the email and if the mailable should parse
    | it as markdown. By default this template utilizes the existing notification
    | layout template. So any modifications that you have made to this layout
    | template (like the header, colors, etc) will be inherited by the view
    | supplied by this package.
    |
    | IMPORTANT: If you decide to supply your own Blade template, make sure that
    | it includes a {!! $content !!} tag as this is what is used to parse the
    | WYSIWYG's content
    |
    */

    'template' => [
        'markdown' => true,
        'view' => 'vendor.custom-email-sender.email'
    ],

    /*
    |--------------------------------------------------------------------------
    | Quill WYSIWYG editor configuration
    |--------------------------------------------------------------------------
    |
    | The basic buttons that come enabled out of the box. These were chosen to
    | eliminate the potential intrusion of the email layout. Other options are
    | available and documented on the Quill website: https://quilljs.com/docs
    |
    */

    'editor' => [

        'toolbar' => [
            [ 'header' => 1 ],
            [ 'header' => 2 ],
            [ 'list' => 'ordered' ],
            [ 'list' => 'bullet' ],
            'bold',
            'italic',
            'link',
        ]
    ],

];

本地化/翻译

在供应商文件发布后,您可以编辑 resources/lang/vendor/custom-email-sender 目录中的必要占位符。

许可协议

Nova Custom Email Sender 是免费软件,根据 MIT 许可协议授权。