Level 7
Have you tried disabling VerifyCsrfToken middleware as a test?
Just in case, comment out 'App\Http\Middleware\VerifyCsrfToken', in app\Http\Kernel.php
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
That's my form:
{!! Form::open(['method'=>'post' ,'action'=>'WelcomeController@sendMail','enctype'=>'plain']) !!}
<div class="form-group">
{!! Form::label('name','Name: ') !!}
{!! Form::text('name',null,['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('email','Email: ') !!}
{!! Form::text('email',null,['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('subject','Subject: ') !!}
{!! Form::text('subject',null,['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('body', 'Message: ')!!}
{!! Form::textarea('body',null,['class'=>'form-control', 'rows'=>'3']) !!}
</div>
{!! Form::submit('Send', ['class'=>'btn btn-primary']) !!}
{!! Form::close() !!}```
sendMail method
{
try
{
$subject = $request->get('subject');
Mail::send('emails.contact', [
'name' => $request->get('name'),
'email' => $request->get('email'),
'subject' => $subject,
'content' => $request->get('content')
], function ($message) use ($subject)
{
$message->to('gabriel.limo@gmail.com', 'Gabriel Moretti')->subject($subject);
});
Flash::info('Email has been sent. ');
} catch (\Exception $e)
{
Flash::error('Something wrong. Try again later');
//log
} finally
{
return redirect('/');
}
}
And the exception:
in compiled.php line 2494
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in compiled.php line 9059
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12216
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in compiled.php line 9059
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 10917
at StartSession->handle(object(Request), object(Closure)) in compiled.php line 9059
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 11922
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in compiled.php line 9059
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 11871
at EncryptCookies->handle(object(Request), object(Closure)) in compiled.php line 9059
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2532
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in compiled.php line 9059
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9050
at Pipeline->then(object(Closure)) in compiled.php line 1945
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 1932
at Kernel->handle(object(Request)) in index.php line 53
It works just fine on my homestead. Already destroyed my server and deployed another one, but still dont work.
@edit I made a misstake on enctype="plain"
Please or to participate in this conversation.