Tojo
Tojo

Reputation: 249

Send mail with laravel using mail function php

I use mail php function for sending mail with laravel. My route:

Route::post('/mailsend', 'Home@contact');

My controller:

public function contact(Request $request){

        $to = '[email protected]';
        $from = $request->input('email');
        $subject = $request->input('subject');
        $message = $request->input('message');
        $headers = 'From: '.$from . "\r\n" .
        'Reply-To: '.$from . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

        mail($to, $subject, $message, $headers);


        return view('contact');
    }

my problem, I can't get my values input in post

enter image description here

Thanks

Upvotes: 0

Views: 605

Answers (1)

Drown
Drown

Reputation: 5982

You're getting this error because you likely forgot to include the CSRF token in the form that submits to that page.

Make sure to include it like this :

<form method="POST>
  <!-- ... -->

  {{ csrf_field() }}
</form>

Upvotes: 1

Related Questions