定制 emchooo/laravel-flymail 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

emchooo/laravel-flymail

Composer 安装命令:

composer require emchooo/laravel-flymail

包简介

Send mails in laravel with custom config you can set on the fly

README 文档

README

About

Laravel Flymail adds Mail::config() method to Laravel\Mail. Config method will setup mail config data on the fly. Use Flymail if you need to send Mails with dynamic credentials you store in DB or other configs. Since it just extends Laravel's Mail and adds config method, everything else remains same.

Installation

composer require emchooo/laravel-flymail

Usage

use Illuminate\Support\Facades\Mail;

// get config file from DB or other source

// SES config
$config = [ 
	'driver' => 'ses', 
	'key' => 'xxx', 
	'secret' => 'xxx', 
	'from' => [ 
		'address' => 'address@mail.com', 
		'name' => 'Name' 
		] 
	];
// SMTP config
$config = [
	'driver' => 'smtp',
	'host' => 'smtp.xxx.io', 
	'port' => 2525,
	'username' => 'xxx',
	'password' => 'xxx',
	'encription' => 'null'
	'from' => [ 
		'address' => 'address@mail.com', 
		'name' => 'Name' 
		]
	];

Mail::config($config)->to($request->user())->send(new OrderShipped($order));

NOTE ON QUEUES

If you use Mail::config than don't use ->queue(); , use ->send(); . If you use queue on Mail then it will use config from /config/mail.php while sending. Might try to fix that one day.

If you need to queue Mail with custom config then use Jobs.

	SendEmail::dispatch($config, $order);
	/**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($config, $order)
    {
        $this->config = $config;
        $this->order = $order;
    }
    
	 /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Mail::config($this->config)
        ->to($this->order->email)
        ->send(new OrderShipped($this->order));
    }

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固