mardi 13 juillet 2021

why my laravel is not sending form data in email

i am trying to send this data to email

dynamic_email_template.blade.php

<p>Hi, This is </p>
<p>I have some query like .</p>
<p>It would be appriciative, if you gone through this feedback.</p>

but problem is that $data['name'] & $data['message'] is missing in received email

in model and controller even i am receiving this data i have checked it using dd($this->data) here is my route

Route::get('/sendemail', 'SendEmailController@index');

Route::post('/sendemail/send', 'SendEmailController@send')->name('send.mail');

my controller

public function send(Request $request)
{
    $data = array(
        'name'      =>  $request->name,
        'message'   =>   $request->message
    );
    
   // dd($data);

 Mail::to('hamzaqureshi401@gmail.com')->send(new SendMail($data));
 return back()->with('success', 'Thanks for contacting us!');

}

my model

    <?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendMail extends Mailable
{
    use Queueable, SerializesModels;
    public $data;

    public function __construct($data)
    {
        $this->data = $data;
    }

    public function build()
    {
        dd($this->data);
        return $this->from('scoops@creamery.pk')->subject('New Customer Equiry')->view('dynamic_email_template')->with('data', $this->data);
    }
}

?>

where i am doing mistake any help will be thankfull



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire