PHP code example of emchooo / laravel-flymail
1. Go to this page and download the library: Download emchooo/laravel-flymail library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
emchooo / laravel-flymail example snippets
use Illuminate\Support\Facades\Mail;
// get config file from DB or other source
// SES config
$config = [
'driver' => 'ses',
'key' => 'xxx',
'secret' => 'xxx',
'from' => [
'address' => '[email protected] ',
'name' => 'Name'
]
];
// SMTP config
$config = [
'driver' => 'smtp',
'host' => 'smtp.xxx.io',
'port' => 2525,
'username' => 'xxx',
'password' => 'xxx',
'encription' => 'null'
'from' => [
'address' => '[email protected] ',
'name' => 'Name'
]
];
Mail::config($config)->to($request->user())->send(new OrderShipped($order));
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));
}