在Laravel 5.1中动态更新STMP配置 [英] Update STMP config on the fly in Laravel 5.1
问题描述
我的邮件发送功能通过在.env
文件上添加配置来起作用.
My mailing functionality works by adding the configs on .env
file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=passwordd
MAIL_FROM=info@text.com
MAIL_NAME=Info
但是我的问题是我不知道如何动态更新此配置.我尝试使用帮助器config()
,但在config('app')
中看不到SMTP值.
But my problem is I don't know how to update this configs dynamically. I've try using the helper config()
but I can't see the SMTP values in config('app')
.
如果您想知道为什么要执行此操作是因为SMTP配置将来自数据库.
In case you're wondering why I want to do this is because the SMTP configs will come from the DB.
我希望这很清楚,否则请告诉我!
I hope this is clear, if not please let me know!
提前谢谢!
推荐答案
也许您可以使用Config::set
方法,如下所示:
Perhaps you can use the Config::set
method, as answered here:
Config::set('key', 'value');
https://stackoverflow.com/a/23438548/385402
但是我认为在发送电子邮件之前直接使用DB值会更好,我不知道是否已经将它们存储在配置文件中(如果已经在数据库中)是否有意义.
but I think it would be better to use DB values directly before sending the email, I don't know if it makes sense that you store them into a config file at all if you already have them in the database.
这篇关于在Laravel 5.1中动态更新STMP配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!