我正在使用 Laravel 4,我想更改 Controller 中的邮件配置(如驱动程序/主机/端口/...),因为我想将配置文件保存在具有不同邮件配置的数据库中。这是使用 config/mail.php 中的配置发送邮件的基本方法
Mail::send(
'emails.responsable.password_lost',
array(),
function($message) use ($responsable){
$message->to($responsable->email, $responsable->getName());
$message->subject(Lang::get('email.password_lost'));
});
我尝试过类似的内容,但没有成功
$message->port('587');
感谢您的支持!
让
最佳答案
您可以使用Config::set
即时设置/更改任何配置:
Config::set('key', 'value');
因此,要设置/更改 mail.php
中的端口,您可以尝试以下操作:
Config::set('mail.port', 587); // default
Note: Configuration values that are set at run-time are only set for the current request, and will not be carried over to subsequent requests. Read more.
关于php - 如何在使用 Laravel Controller 中发送邮件之前更改邮件配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23438342/