
Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions. You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root. For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Common;
|
|
|
|
use Exception;
|
|
|
|
class CommonMailer
|
|
{
|
|
public function setSmtpDriver($config)
|
|
{
|
|
try {
|
|
if (! $config) {
|
|
return false;
|
|
}
|
|
$https = [];
|
|
$https['ssl']['verify_peer'] = false;
|
|
$https['ssl']['verify_peer_name'] = false;
|
|
$transport = new \Swift_SmtpTransport($config['host'], $config['port'], $config['security']);
|
|
$transport->setUsername($config['username']);
|
|
$transport->setPassword($config['password']);
|
|
$transport->setStreamOptions($https);
|
|
$set = new \Swift_Mailer($transport);
|
|
|
|
// Set the mailer
|
|
\Mail::setSwiftMailer($set);
|
|
|
|
return true;
|
|
} catch (Exception $e) {
|
|
loging('mail-config', $e->getMessage());
|
|
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
|
|
public function setMailGunDriver($config)
|
|
{
|
|
if (! $config) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|