【问题标题】:Send Mail not working in Laravel 5.1发送邮件在 Laravel 5.1 中不起作用
【发布时间】: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


【解决方案1】:

Mail::send('emails.otp_mail_format', ['otp'=>$user_otp], 函数($message) 使用 ($uEmailAddress) { $message->to($uEmailAddress)->from('no-reply@exaple.com','App Name')->subject('MyApp:: Account Verification'); });

【讨论】:

    猜你喜欢
    • 2015-03-20
    • 2016-02-17
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    • 2017-03-07
    • 1970-01-01
    • 1970-01-01
    • 2017-11-04
    相关资源
    最近更新 更多