wedevelop4you/laravel-multiple-mailers 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wedevelop4you/laravel-multiple-mailers

Composer 安装命令:

composer require wedevelop4you/laravel-multiple-mailers

包简介

Adds multiple mailers

README 文档

README

I made this package because I wanted to use multiple mails. It is a small simple package to use multiple mails in Laravel. I'm not really going to expand it any further. Only if I want to add functions myself. You are free to use the package and here is a little explanation of how to use it.

Installation

PHP 7.0 or higher and Laravel 7 or higher are required.

Require this package with composer.

composer require wedevelop4you/laravel-multiple-mailers

Publish the config file by running:

php artisan vendor:publish --provider="WeDevelop4You\LaravelMultipleMailers\Providers\MailerServiceProvider" --tag=config

Config

config the mailers in: multiple-mailer

Accounts config:

    /*
     *  'Choose a name for your mail config' => [
     *	    'username' => 'Your email address', (required)
     *      'password' => 'Your email password', (required)
     * 	    'name' => 'Your name send by the email' (The default name is MAIL_FROM_NAME in your .env file)
     * 	    'provider' => 'Your provider' (The default provider is default)
     *  ]
     */
    'accounts' => [
        'example' => [
            'username' => 'mailer@example.org',
            'password' => env('MAIL_PASSWORD'),
        ]
    ]
name type required default
name mail config object true null
username string true null
password string true null
name string false MAIL_FROM_NAME in your .env file
produces string false default

Providers config:

    /*
     *	The providers are the same as mailers in the mail config
     */
    'provider' => [
        'default' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST'),
            'port' => env('MAIL_PORT'),
            'encryption' => env('MAIL_ENCRYPTION'),
            'timeout' => null,
            'auth_mode' => null,
        ],
    ]

Queue config:

     /*
     *  'worker' => The name of the queue worker. (The default name of the worker is 'default')
     *  'default' => Always use the queue worker name on mail classes with ShouldQueue.
     */
    'queue' => [
        'worker' => '',
        'default' => false,
    ]

If you want to queue all the mail on the same worker name but except one or more, Than you can set onQueue in your mail class. The code will not override the queue name.

How to use it

When sending an email you need to set the mailer. The mailer name is the name you set in the mailer config.

Mail::mailer('example');

Example:

Mail::mailer('example')->to('test@example.org')->send(new ExampleMail());

Now import MultipleMailer in your mail class.

use Queueable, SerializesModels, MultipleMailer;

Finally set the mailer name in your mail class in the __construct or in your own function. You need to give it the same name as above

$this->setMultipleMailerName('example');

Examples:

    public function __construct()
    {
        $this->setMultipleMailerName('example');
    }

Exceptions

MailerAccountNotFoundException

throws when the mailer name doesn't exist in the config file.

MailerProviderNotFoundException

throws when the provider name doesn't exist in the config file.

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固