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

tiagoribeiro317691
tiagoribeiro317691

Hi, I've followed the steps at http://octobercms.com/theme/support/jtherczeg-multi/contact-form

I managed to configure my email, create a template and test sending a message, which I receive. However, my contact form still does not work.

This is my HTML code at Partials > contact.htm

    <div class="container-wrapper">
        <div class="container">
            <div class="row">
                <div class="col-sm-4 col-sm-offset-8">
                    <div class="contact-form">
                        <h3>Contact Info</h3>

                        <form id="main-contact-form" name="contact-form" data-request="onSend" data-request-success="alert('We have recieved your email.. we\'ll get back to you shortly’); this.reset();" data-request-error=“alert(jqXHR.responseText);”>
                            <div class="form-group">
                                <input type="text" name="name" class="form-control" placeholder="Name" required>
                            </div>
                            <div class="form-group">
                                <input type="email" name="email" class="form-control" placeholder="Email" required>
                            </div>
                            <div class="form-group">
                                <input type="text" name="subject" class="form-control" placeholder="Subject" required>
                            </div>
                            <div class="form-group">
                                <textarea name="body" class="form-control" rows="8" placeholder="Message" required></textarea>
                            </div>
                            <button type="submit" class="btn btn-primary">Send Message</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

And this is my code at layouts > default.htm (on the "Code" tab):


function onSend()
{
    // Collect input
    $name = post('name');
    $email = post('email');
    $subject = post('subject');
    $body = post('body');

    // Form Validation
    $validator = Validator::make(
        [
            'name' => $name,
            'email' => $email,
            'subject' => $subject,
            'body' => $body,
        ],
        [
            'name' => 'required',
            'email' => 'required|email',
            'subject' => 'required',
            'body' => 'required',
        ]
    );

    if ($validator->fails())
    {
        $messages = $validator->messages();
        throw new ApplicationException($messages->first());
    }

    // All is well -- Submit form
    $to = System\Models\MailSettings::get('sender_email');
    $params = compact('name','email','subject','body');
    Mail::sendTo($to, 'contactapp.flexicontact::mail.contactform', $params);
    return true;
}

When I submit the form, I receive the message that the email has been sent, however the email is not sent.

Can you provide me with guidance on this? Thanks all.

Last updated

mnshankar
mnshankar

Are you able to go into backend->settings->mail->mail templates, open contactapp.flexicontact::mail.contactform, click on "send test message" and get your email delivered?

If not, you may need to edit your config/email.php file and add in your email provider details.

rambabooknit27896

1-3 of 3

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