Skip to content

Instantly share code, notes, and snippets.

@abdasis
Created August 17, 2024 02:32
Show Gist options
  • Save abdasis/f7c4a72453f5349a0d7d5d40e5e75605 to your computer and use it in GitHub Desktop.
Save abdasis/f7c4a72453f5349a0d7d5d40e5e75605 to your computer and use it in GitHub Desktop.
Membuat config email dengan data dari database
<?php
namespace App\Providers;
use App\Settings\Smtp;
use Config;
use Illuminate\Support\ServiceProvider;
class MailConfigServiceProvider extends ServiceProvider
{
public function register(): void
{
}
public function boot(Smtp $smtp): void
{
$config = array(
'driver' => 'smtp',
'host' => $smtp->host,
'port' => $smtp->port,
'from' => array('address' => $smtp->mail_from_address, 'name' => $smtp->mail_from_name),
'encryption' => $smtp->encryption,
'username' => $smtp->username,
'password' => $smtp->password,
);
Config::set('mail', $config);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment