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

codypersinger13719
codypersinger13719

Hey guys, I've read what feels like a thousand topics on simple email contact forms in October, so please forgive me for another similar post - but I haven't found a solution to this issue anywhere. I'm attempting to set up a contact form by following these steps:

  1. Create a new form. I've tried adding this directly to a page, and have also tried adding it to a partial, then importing the partial to a page.
    <form class="form-contact" data-request="onSend">
        <input type="text" name="username" required="required" placeholder="Your Name">
        <textarea name="usermessage" placeholder="Message text" required="required"></textarea>
        <div>
            <button type="submit">Submit</button>
            <button type="reset">Reset</button>
        </div>
    </form>
  2. Define the onSend function. I've tried to do this in the Code tab of the Layout, the Code tab of the Page, and even the Code tab of the Partial.

    function onSend(){
    $name = post('username');
    $content = post('usermessage');
    
    $params = compact('name','content');
    Mail::sendTo('mytestemail@gmail.com', 'csi.website::mail.contactform', $params);
    return true;
    }

    Note: I'm using a real email, not actually "mytestemail@gmail.com".

  3. Configure mail for SMTP via Gmail.

  4. Create a mail template with the code "csi.website::mail.contactform".

  5. Send a test email from the "csi.website::mail.contactform" template. At this point I receive the email without issues.

  6. Use the contact form on the live website - I do not receive the email. When I click submit, the onSend() method seems to be called successfully. I get a loading indicator which then goes away. If I use data-request-success and data-request-error on the form to send alerts, the success alert is always triggered. However, I never receive the email.

Can anyone please help me to understand the issue? It seems strange that the test email works perfectly, but the contact form never works at all. I've also tried going down a different route and writing a custom plugin to contain the onSend() method but I had pretty much exactly the same issue there. Please help!

Last updated

codypersinger13719
codypersinger13719

I've continued to try several different variations of this setup process, including putting whole form (html and php both) into a custom plugin. I've also tried adding parenthesis to data-request="onSend()" and other such small changes. As far as I can see I'm following the documentation and the recommendations I've seen on the forum. I'd really appreciate any help anyone could provide.

GizzmoAsus
GizzmoAsus

Mine works when I use the following mail send code:

...
$vars = [
   'name' => Input::get('name'),
   etc...
]
Mail::send('kelcode.contact::mail.message', $vars, function($message) {
     $message->to(Settings::get('recipient_address'));
     $message->subject(Settings::get('recipient_subject'));
});
...

Last updated

arrcrown
arrcrown

codypersinger13719 said:

Hey guys, I've read what feels like a thousand topics on simple email contact forms in October, so please forgive me for another similar post - but I haven't found a solution to this issue anywhere. I'm attempting to set up a contact form by following these steps:

  1. Create a new form. I've tried adding this directly to a page, and have also tried adding it to a partial, then importing the partial to a page.
    <form class="form-contact" data-request="onSend">
       <input type="text" name="username" required="required" placeholder="Your Name">
       <textarea name="usermessage" placeholder="Message text" required="required"></textarea>
       <div>
           <button type="submit">Submit</button>
           <button type="reset">Reset</button>
       </div>
    </form>
  2. Define the onSend function. I've tried to do this in the Code tab of the Layout, the Code tab of the Page, and even the Code tab of the Partial.

    function onSend(){
    $name = post('username');
    $content = post('usermessage');
    
    $params = compact('name','content');
    Mail::sendTo('mytestemail@gmail.com', 'csi.website::mail.contactform', $params);
    return true;
    }

    Note: I'm using a real email, not actually "mytestemail@gmail.com".

  3. Configure mail for SMTP via Gmail.

  4. Create a mail template with the code "csi.website::mail.contactform".

  5. Send a test email from the "csi.website::mail.contactform" template. At this point I receive the email without issues.

  6. Use the contact form on the live website - I do not receive the email. When I click submit, the onSend() method seems to be called successfully. I get a loading indicator which then goes away. If I use data-request-success and data-request-error on the form to send alerts, the success alert is always triggered. However, I never receive the email.

Can anyone please help me to understand the issue? It seems strange that the test email works perfectly, but the contact form never works at all. I've also tried going down a different route and writing a custom plugin to contain the onSend() method but I had pretty much exactly the same issue there. Please help!

codypersinger13719 i got the same issue. did you already fix it?

pardeep_kumar9329793
pardeep_kumar9329793

<?php $toEmail = "pardeepkumargt@gmail.com";

$mailHeaders = "From: " . $_POST["your_name"] . "<". $_POST["your_email"] .">\r\n";

if(mail($toEmail, $_POST["comments"], $_POST["your_phone"], $mailHeaders)) {

echo"

Contact Mail Sent.

";

}

else {

echo"

Problem in Sending Mail.

"; }

?> Send mail with easy function mail() and for full code check Cloudways blog How To Create A PHP Contact Form With MySQL & HTML5 Validation

virgo9793756674
virgo9793756674

Hi guys, I need your help urgently, I want to make a contact page work, I don't have much experience in October because I made my normal html template and the form is as follows. <form class = "form-contact contact_form" action = "contact.php" method = "post" id = "contactForm" novalidate = "novalidate"> <div class = "row"> <div class = "col-12"> <div class = "form-group"> <textarea class = "form-control w-100" name = "message" id = "message" cols = "30" rows = "9" onfocus = "this.placeholder = ''" onblur = "this.placeholder = ' Enter Message '"placeholder =" Enter Message "> </textarea> </div> </div> <div class = "col-sm-6"> <div class = "form-group"> <input class = "form-control valid" name = "name" id = "name" type = "text" onfocus = "this.placeholder = ''" onblur = "this.placeholder = 'Enter your name'" placeholder = "Enter your name"> </div> </div> <div class = "col-sm-6"> <div class = "form-group"> <input class = "form-control valid" name = "email" id = "email" type = "email" onfocus = "this.placeholder = ''" onblur = "this.placeholder = 'Enter email address'" placeholder = "Email"> </div> </div> <div class = "col-12"> <div class = "form-group"> <input class = "form-control" name = "subject" id = "subject" type = "text" onfocus = "this.placeholder = ''" onblur = "this.placeholder = 'Enter Subject'" placeholder = "Enter Subject "> </div> </div> </div> <div class = "form-group mt-3"> <button name = "send" type = "submit" class = "button button-contactForm boxed-btn"> Send </button> </div> </form>

So I do not know how to handle php in October. I need to make it work to send messages to the mail. I could not do it. Not with someone, a recommendation is important and I am desperate I did not find a solution thanks to everything

virgo9793756674
virgo9793756674

codypersinger13719 said:

Hey guys, I've read what feels like a thousand topics on simple email contact forms in October, so please forgive me for another similar post - but I haven't found a solution to this issue anywhere. I'm attempting to set up a contact form by following these steps:

  1. Create a new form. I've tried adding this directly to a page, and have also tried adding it to a partial, then importing the partial to a page.

    <form class="form-contact" data-request="onSend">
       <input type="text" name="username" required="required" placeholder="Your Name">
       <textarea name="usermessage" placeholder="Message text" required="required"></textarea>
       <div>
           <button type="submit">Submit</button>
           <button type="reset">Reset</button>
       </div>
    </form>
  2. Define the onSend function. I've tried to do this in the Code tab of the Layout, the Code tab of the Page, and even the Code tab of the Partial.

    function onSend(){
    $name = post('username');
    $content = post('usermessage');
    
    $params = compact('name','content');
    Mail::sendTo('mytestemail@gmail.com', 'csi.website::mail.contactform', $params);
    return true;
    }

    Note: I'm using a real email, not actually "mytestemail@gmail.com".

  3. Configure mail for SMTP via Gmail.

  4. Create a mail template with the code "csi.website::mail.contactform".

  5. Send a test email from the "csi.website::mail.contactform" template. At this point I receive the email without issues.

  6. Use the contact form on the live website - I do not receive the email. When I click submit, the onSend() method seems to be called successfully. I get a loading indicator which then goes away. If I use data-request-success and data-request-error on the form to send alerts, the success alert is always triggered. However, I never receive the email.

Can anyone please help me to understand the issue? It seems strange that the test email works perfectly, but the contact form never works at all. I've also tried going down a different route and writing a custom plugin to contain the onSend() method but I had pretty much exactly the same issue there. Please help!

hello brother i am new in october i made a form is as follows. <form class = "form-contact contact_form" action = "contact.php" method = "post" id = "contactForm" novalidate = "novalidate"> <div class = "row"> <div class = "col-12"> <div class = "form-group"> <textarea class = "form-control w-100" name = "message" id = "message" cols = "30" rows = "9" onfocus = "this.placeholder = ''" onblur = "this.placeholder = ' Enter Message '"placeholder =" Enter Message "> </textarea> </div> </div> <div class = "col-sm-6"> <div class = "form-group"> <input class = "form-control valid" name = "name" id = "name" type = "text" onfocus = "this.placeholder = ''" onblur = "this.placeholder = 'Enter your name'" placeholder = "Enter your name"> </div> </div> <div class = "col-sm-6"> <div class = "form-group"> <input class = "form-control valid" name = "email" id = "email" type = "email" onfocus = "this.placeholder = ''" onblur = "this.placeholder = 'Enter email address'" placeholder = "Email"> </div> </div> <div class = "col-12"> <div class = "form-group"> <input class = "form-control" name = "subject" id = "subject" type = "text" onfocus = "this.placeholder = ''" onblur = "this.placeholder = 'Enter Subject'" placeholder = "Enter Subject "> </div> </div> </div> <div class = "form-group mt-3"> <button name = "send" type = "submit" class = "button button-contactForm boxed-btn"> Send </button> </div> </form>

Which is sent to contact.php, so I have seen that the form submission is not the same, could you help me to tell me where the php code is put in the page that I make contact? I have been stuck for 6 days. Thank you

1-7 of 7

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