我正在使用Laravel 5.1
我创建了一个函数来从db获取smtp信息用户$mail_config = STMPDetails :: where(‘user_id’,36) – > first()然后我可以调用config helper函数并传递数组来设置配置值配置($mail_config).然后我调用Mail :: queue函数.
但在它到达createSmtpDriver@vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php之前,它再次读取配置以发送邮件,邮件配置将更改为.env文件中指定的配置.
另外需要注意的是邮件发送功能是在监听器中
我无法确定在何处可以调用该函数,以便在发送邮件之前保留配置更改.
谢谢,
ķ
解决方法:
这应该工作:
// Set your new config
Config::set('mail.driver', $driver);
Config::set('mail.from', ['address' => $address, 'name' => $name]);
// Re execute the MailServiceProvider that should use your new config
(new Illuminate\Mail\MailServiceProvider(app()))->register();
标签:php,laravel,laravel-5,laravel-5-1
来源: https://codeday.me/bug/20190823/1701707.html