如何将数据从控制器传递到我的自定义邮件查看?
这是控制器的发送邮件方式:
$data = array($user->pidm, $user->password);
Mail::send('emails.auth.registration', $data , function($message){
$message->to(Input::get('Email'), 'itsFromMe')
->subject('thisIsMySucject');
这是我的电子邮件.auth.registration 查看
<p>You can login into our system by using login code and password :</p>
<p><b>Your Login Code :</b></p> <!-- I want to put $data value here !-->
<p><b>Your Password :</b></p> <!--I want to put $password value here !-->
<p><b>Click here to login :</b> www.mydomain.com/login</p>
提前致谢。
答案 0 :(得分:23)
发送这样的数据。
$data = [
'data' => $user->pidm,
'password' => $user->password
];
您可以直接在电子邮件广告素材中的$data
和$password
访问它
答案 1 :(得分:12)
$data = [
'data' => $user->pidm,
'password' => $user->password
];
send方法的第二个参数将数组$ data传递给查看页面
Mail::send('emails.auth.registration',["data1"=>$data] , function($message)
现在,在您的视图页面中,使用可以使用$ data作为
User name : {{ $data1["data"] }}
password : {{ $data1["password"] }}
答案 2 :(得分:0)
回调参数可用于进一步配置邮件。签出以下示例:
Mail::send('emails.dept_manager_strategic-objectives', ['email' => $email], function ($m) use ($user) {
$m->from('info@primapluse.com', 'BusinessPluse');
$m->to($user, 'admin')->subject('Your Reminder!');
});
答案 3 :(得分:0)
对于使用simpleMail的用户可能会有所帮助:
$message = (new MailMessage)
->subject(Lang::getFromJson('Verify Email Address'))
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
->action(Lang::getFromJson('Verify Email Address'), $verificationUrl)
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
$message->viewData['data'] = $data;
return $message;