Muhammad Sipra
Muhammad Sipra

Reputation: 846

Send Mail Function is not working in laravel 5.3

I have a send mail function in CommonHelper like

   public static function send_plain_email($data){
   $contact_email = CommonHelper::$admin_info['contact_email'];
   $data['subject']= 'contact us';

  Mail::send('emails.'.'plain_email', $data, function($message) use ($data , $contact_email) {
    $message->from($data['email']);
    $message->subject($data['subject']);
    $message->to($contact_email);
    if(!empty($attachment)){
      $message->attach($attachment);
    }
  });
}

The data array is coming in this function but Mail::send function giving the following error

 {
 "success": false,
 "message": "Undefined variable: data"
 }

Which part of the code i am missing here ? any ideas ?

Upvotes: 1

Views: 243

Answers (1)

Teh Choon siang
Teh Choon siang

Reputation: 23

check if your blade file have the blade naming extension at the back as follow: file_name.blade.php

Before that i forgot add .blade file extension behind the file name which show as file_name.php it could not detect any variable been sent to the blade.

To display specific data use the following format: {{ $merchant->name }}

Hope this help.

Upvotes: 1

Related Questions