4 years ago

Email Form, How to pass a Variable from Form to Controller

Posted 4 years ago by dcdamianchase

Hi, I am new to l5 and Ive been trying to figure this out for the past 2 days and I still cannot work it out.

I am trying to set the $message->from('email@email.com'); as the email input from the form instead of a static email.

this is my controller

public function create() { return view('contact'); }

public function store(ContactFormRequest $request)

            'subject' => $request->get('subject'),
            'firstname' => $request->get('firstname'),
            'lastname' => $request->get('lastname'),
            'email' => $request->get('email'),
            'user_message' => $request->get('message')
        ), function($message)

            $message->to('email@gmail.com', 'Admin')->subject('New Subject');

        $success = 'Thank you for contacting us. Your message has been sent sucessfuly.';

return \Redirect::route('contact')->with('success', $success);

Please sign in or create an account to participate in this conversation.