51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Http\Facade\SignRSA;
|
|
use App\Models\Setting;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Crypt;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class MailConfigServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Bootstrap services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$mail = Setting::where('key', 'smtp')->first();
|
|
$setting = Setting::where('key', 'setting')->first();
|
|
if ($mail) {
|
|
$mail = (object)json_decode($mail->value);
|
|
|
|
$config = array(
|
|
'driver' => $mail->transport,
|
|
'host' => $mail->host,
|
|
'port' => $mail->port,
|
|
'from' => array('address' => $mail->user, 'name' => json_decode($setting->value)->company),
|
|
'encryption' => $mail->encryption === 0 ? 'tls' : $mail->encryption,
|
|
'username' => $mail->user,
|
|
'password' => $mail->password ? SignRSA::DecryptFunc($mail->password) : ""
|
|
);
|
|
|
|
Config::set('mail', $config);
|
|
}
|
|
}
|
|
}
|