Laravel Mail :: send, how to send data to mail View

How can I transfer data from my Controller to my configured View mail ?

Here's my controller dispatches the post method:

$data = array($user->pidm, $user->password);
Mail::send('emails.auth.registration', $data , function($message){
$message->to(Input::get('Email'), 'itsFromMe')
        ->subject('thisIsMySucject');

      

Here's my email addresses .auth.registration View

<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>&nbsp;www.mydomain.com/login</p>

      

Thanks in advance.

+7


source to share


3 answers


Send data as follows.

$data = [
           'data' => $user->pidm,
           'password' => $user->password
];

      



You can access it directly as $data

and $password

e-mail client

+25


source


$data = [
       'data' => $user->pidm,
       'password' => $user->password
];

      

the second argument of the send method passes the $ data array to view the page

Mail::send('emails.auth.registration',["data1"=>$data] , function($message)

      



Now in your pageview page you can use $ data like

User name : {{ $data1["data"] }}
password : {{ $data1["password"] }}

      

+13


source


The callback argument can be used to further customize the mail. Checkout using the following example:

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!');
});

      

0


source







All Articles