0

My Laravel app allows users to modify email templates, then save them to database.

Sample:

Customer {{ $customer_name }} has accepted your proposed timing {{ $timing }} for PO {{ $po_no }}

(User can change 'customer' to 'client' etc.. but leave the {{ }} intact )

The app then loads dynamic data below into above template.

$data = array('customer_email'=> "email@mail.com", 'timing'=> "2pm",'po_no' => "PO001" );

Then email those rendered text to some emails.

How can I do that?

Rephrase:

  1. load text from db
  2. make it a Blade template
  3. render that template with data

I get stuck at #2

hour man
  • 33
  • 7

1 Answers1

0

add email view to your views/emails folder
ex: mail_template.blade.php

Customer {{ $customer_name }} has accepted your proposed
 timing {{ $timing }} for PO {{ $po_no }}

send method

Mail::send('emails.mail_template', array('customer_email'=> "email@mail.com", 'timing'=> "2pm",'po_no' => "PO001" ), function($message)
            {
                $message->to('sendto@gmail.com')->subject('your email subject');
            });

further read Official Doc

Alupotha
  • 9,710
  • 4
  • 47
  • 48