This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

surajgupta220933958
surajgupta220933958

I am using simple contact from which is in .htm format and the email is getting send but i do not get any success response. Someone please let me know is there is any way to get response on contact.htm cms page Please have a look at my code below

<?php namespace stmortiz\Contact\Components;

use Cms\Classes\ComponentBase; use Input; use Mail; use Db; use table; use Validator; use Redirect;

class ContactForm extends ComponentBase { public function componentDetails(){ return [ 'name' => 'Contact Form', 'description' => 'Contact form' ]; }

public function onSend(){
    $validator = Validator::make(
        [
            'name' => Input::get('name'),
            'email' => Input::get('email'),
            'content' => Input::get('content')
        ],
        [
            'name' => 'required|min:3',
            'email' => 'required|email',
            'content'=> 'required'
        ]
    );

    if($validator->fails()){
        return Redirect::back()->withInput()->withErrors($validator);
    } else {

        $vars = ['name' => Input::get('name'), 'email' => Input::get('email'), 'content' => Input::get('content')];

        Mail::send('stmortiz.contact::mail.message', $vars, function($message) {
            $user = Db::table('backend_users')->where('id', '1')->first();;
            $message->to( $user->email, $user->first_name);
            $message->subject('New message from contact form');

        });
    }

}

}

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.