I have set my email function and I can get my form data but not able to send them,
Undefined variable: name
dd
array:6 [▼
"name" => "tester"
"email" => "[email protected]"
"subject" => "testing emails"
"issue" => "Other"
"budget" => "100"
"messagetext" => "hello there,"
]
My function
public function sendemailtoadmin(Request $request){
$this->validate($request, array(
'name' => 'required|max:255',
'email' => 'required|email',
'issue' => 'required',
'budget' => 'nullable|numeric',
'messagetext' => 'required|min:10|max:15000|string',
'subject' => 'required',
));
$data = array(
'name' => $request->name,
'email' => $request->email,
'subject' => $request->subject,
'issue' => $request->issue,
'budget' => $request->budget,
'messagetext' => $request->messagetext,
);
Mail::send(new ContactForm(), $data, function($message) use ($data) {
$message->from($data['email']);
$message->to('[email protected]');
$message->subject($data['subject']);
});
Session::flash('flash_message', 'Your Email was sent. We will contact you shortly.');
return redirect()->back();
}
My email template
@component('mail::message')
<p>
Name :{{ $name}}<br>
Email address : {{ $email }}<br>
Type of issue: {{ $issue}}<br>
Subject : {{ $subject }}<br>
Budget : {{ $budget }}<br>
Message : {{ $messagetext}}
</p>
Thanks,<br>
{{ config('app.name') }}
@endcomponent
Any idea?
I have changed new ContactForm()
to 'my.view.address'
and used HTML view
instead of markdown.