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

rick20058
rick20058

Hello all,

This is my fist time building a website in October CMS. In the current setup I have a custom form that sends an email.

My layout file:

use Illuminate\Support\Facades\Mail;
function onSend() {
    $data = Input::all();
    Mail::send('mail.inforequest', $data, function ($message) {
        $message->from(post('email'), post('name'));
        $message->to('info@inchplastics.nl')->subject('Aanvraag via de website');
   });
}

I already figured out it's sending an AJAX request to contact.php, but as far as I can see I have no contact.php. As I read in previous topics the contact form needs to be in a partial, so did I. Below my form attributes.

 id="contact-form" data-request="onSend" method="post" action="#"

Can someone direct me in the right direction on how to solve this?

Last updated

rick20058
rick20058

No one? Today I tried with this tutorial (https://www.youtube.com/watch?v=Ki8eRIdipKc) to build a custom plugin to easily send emails. But for some stupid reason it redirects to "contact.php"

form id="contact-form" data-request="{{__SELF__}}::onSend"

Frontend result:

data-request="contactform::onSend"

Controller code:

use Cms\Classes\ComponentBase;
use Input;
use Mail;

/**
* 
*/
class ContactForm extends ComponentBase
{

    public function componentDetails()
    {
        return [
            'name' => 'Contact Form',
            'description' => 'Simple contact form'
        ];
    }

    public function onSend()
    {
        $vars = ['name' => Input::get('name'), 'email' => Input::get('email'), 'company' => Input::get('company'), 'phone' => Input::get('phone'), 'message' => Input::get('comment')];

        Mail::send('test.contactform::mail.message', $vars, function($message) {
            $message->to('test@test.nl');
            $message->subject('Aanvraag via de website');
        });
    }
}

Last updated

1-2 of 2

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