在Laravel 5.1中动态更新STMP配置 [英] Update STMP config on the fly in Laravel 5.1

查看:104
本文介绍了在Laravel 5.1中动态更新STMP配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的邮件发送功能通过在.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆