Home How to Send email with html templates in laravel 5?
Reply: 4

How to Send email with html templates in laravel 5?

Rajdip69869 Published in 2018-01-10 06:20:37Z

i want to try simple email sent like in php but i get templates based email sending in Laravel 5 ??

`$to      = Session::get('email');
 $subject = 'Order confirmation';
 $headers = "MIME-Version: 1.0\r\n";
 $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
 $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
 $headers .= "From: Test <rajdipvekriya1992@gmail.com>"; 
 $message = 'test body';
 mail($to, $subject, $message, $headers);`

but i want get templates based body html pass $message like to

 $body = $this->load-
Yogesh Paliyal
Yogesh Paliyal Reply to 2018-01-10 07:18:04Z

have a look to this code, this will surely help you.

   $to = "somebody@example.com";
   $subject = "My subject";
   $txt = "Hello world!";
   $headers = "From: webmaster@example.com" . "\r\n" .
   "CC: somebodyelse@example.com";
Mahdi Younesi
Mahdi Younesi Reply to 2018-01-10 06:27:37Z

create a Mailable class with make command

php artisan make:mail

then write your code in handle method

 * Build the message.
 * @return $this
public function build()
  return $this->view('emails.complaint-reply')
        ->subject('Cotint Group')

And in emails.complaint-reply.blade.php file write down your HTML template

bruddah Reply to 2018-01-10 06:52:21Z

I think Mail::raw is what you need:

Mail::raw('Text to e-mail', function($message)
    $message->from('us@example.com', 'Laravel');


Saly Reply to 2018-01-10 07:19:47Z

Use Mail::send like this

\Mail::send('view', $data, function ($message)
    $message->subject('Email Subject');

and create view.blade.php, write in laravel blade.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305174 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO