【发布时间】:2018-06-25 00:33:59
【问题描述】:
我创建了一个用于发送邮件的演示。 我在它正在工作的联系页面中发送邮件。 但是当我为 TO 使用动态电子邮件时,它就不起作用了。
不工作
Mail::send('emails.otp_mail_format',['otp'=>'123456'],
function($message){
$message->from('no-reply@example.com');
$message->**to($uEmailAddress)**->subject('AccountVerification');
});
但在代码下面工作
Mail::send('emails.otp_mail_format',['otp'=>'123456'],
function($message){
$message->from('no-reply@example.com');
$message->**to('kanu@example.com')**->subject('AccountVerification');
});
to('example@gmail.com') 正在工作
但是to($uEmailAddress)那就不行了
.
【问题讨论】:
-
你有没有检查 uEmailAddress 在那个调用时的值是多少?当你说“不工作”时,你能更具体一点吗?
-
我得到了价值。
-
你介意分享一下它是什么吗?
-
我创建了 sendMail 函数并传递了两个参数(电子邮件和 otp),例如: public function sendMail($uEmailAddress = null,$otp=null) { Mail::send('emails.otp_mail_format' ,['otp'=>'123456'], function($message){ $message->from('no-reply@example.com'); $message->to($uEmailAddress)->subject('Account确认'); }); }
-
请提供任何替代方案
标签: laravel-5.1