Currently I want to configure my application in Laravel with dynamic database data for mail delivery. That is, host, port, driver, user, password
I want to take them from database. How can I make the settings?
In the config/mail.php
are the values that are passed to .env
. Is there a way to pass a variable with the data of all the fields?
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 465),
I modified it to this and it still does not work as you mention
'$conf = ConfMail::find(1);
config([
'mail.driver' => $conf->driver,
'mail.host' => $conf->host,
'mail.port' => $conf-port,
'mail.from' => [
'mail.address' => $conf->email,
'mail.name' => $conf->name],
'mail.encryption' => $conf->encryption,
'mail.username' => $conf->user,
'mail.password' => $conf->password
]);
I do not know if the config lacks something.