We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47401
    • 295 Posts
    I would test the environment out by writing a little PHP script using the send mail function. this will determine if there is a problem with the environment. it could be the php.ini, or modx doesnt have rights to send email. you need to ensure that there is a valid from email address (an achual mailbox existing on the same domain) also, and ensure that there is a local mail server on your hosting, and that the mail server is of course up and running (this can be tested using telnet to port 25) or 993 if using TLS.
      • 36435
      • 40 Posts
      Hi Jay.

      I'd tried that before, and again just now. Stripped the form down to just the bare minimum. I've tried again both wth and without SMTP Also triple and quadruple-checked the chunk

      <h2>Email From the Curious&Creative Website</h2>
      
      <p>Name: [[+name]]</p>
        
      <p>Email: [[+email]]</p>
       
      <p>Phone: [[+phone]]</p>
       
      <p>Enquiry: <br />[[+text]]</p>


      I tested using Formkeep, an online service for manging forms.

      if you have an existing form, simply modify your site's form tag like so:

      <form accept-charset="UTF-8" action="https://formkeep.com/f/***" method="POST">


      When I tried it on my Formit form, I was stuck with the same results. I then created an ordinary HTML form, pasted the tag and it worked. Which was great - except the service costs about $20 a month, which I can't pass on to my client.

      If I were to use a normal HTML/php contact form, is there anything I need to consider to get it to work in ModX? (when I tried the HTML form without FormKeep's script, it still wasn't working)

      Thanks
        • 36435
        • 40 Posts
        Quote from: comp_nerd26 at Jan 27, 2016, 04:29 PM
        I would test the environment out by writing a little PHP script using the send mail function. this will determine if there is a problem with the environment. it could be the php.ini, or modx doesnt have rights to send email. you need to ensure that there is a valid from email address (an achual mailbox existing on the same domain) also, and ensure that there is a local mail server on your hosting, and that the mail server is of course up and running (this can be tested using telnet to port 25) or 993 if using TLS.

        Hi Comp_Nerd
        Unfortunately, my php skills are quite lacking. Any chance you could point me to where I can learn how to do that, or even a sample script?

        Also, isn't that what Rob's Quickemail does, or is this a bit more detailed?
          • 47401
          • 295 Posts
          Hi

          Create a snippet, give it a name, lets say call it 'mailcheck'. in your formit hooks, remove everything and just add the snippet 'mailcheck'

          in the snippet you could put something like this

          
          $message = "Sending a Test email to a valid email address.  looks like you got it ok";
           
                  $modx->getService('mail', 'mail.modPHPMailer');
                  $modx->mail->set(modMail::MAIL_BODY,$message);
                  $modx->mail->set(modMail::MAIL_FROM,'[email protected]');
                  $modx->mail->set(modMail::MAIL_FROM_NAME,'CHANGEME');
                  $modx->mail->set(modMail::MAIL_SUBJECT,'ERROR LOG');
                  $modx->mail->address('to','[email protected]');
                  $modx->mail->address('reply-to','[email protected]');
                  $modx->mail->setHTML(true);
                  if (!$modx->mail->send()) {
                      $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
                  }
                  $modx->mail->reset();
          return true;
          


          change email addresses with VALID email addresses!
          change the message string(if you like)

          The next time you submit the form, goto reports -> error log and you should see an error message of why modx wont send the email. this will help you to troubleshoot your environment. if no error message is recorded then you know modx is connecting to the mail server ok.
            • 36435
            • 40 Posts
            Hi. Thanks for that.

            I gave it a shot - I wasn't sure what you meant when by remove all the hooks, (if just the hooks or clear the whole formit call, so I tried both:

            [[!FormIt?
               &hooks=`mailcheck`
               &emailTpl=`mailChunk`
               &emailTo=`***@curiousandcreative.co.za`
               &emailFrom=`***@curiousandcreative.co.za`
               &emailSubject=`WEBSITE ENQUIRY`
               &redirectTo=`60`
               &validate=`name:required,
                   email:email:required,
                   text:required:stripTags,
                   nospam:blank`
               &submitVar=`form-submit`       
            ]] 


            and

            [[!FormIt?
              &hooks=`mailcheck`       
            ]] 


            Both had the same result - nothing, and my error log is still empty :/
              • 47401
              • 295 Posts
              Quote from: justimaging at Jan 27, 2016, 06:29 PM
              Hi. Thanks for that.

              I gave it a shot - I wasn't sure what you meant when by remove all the hooks, (if just the hooks or clear the whole formit call, so I tried both:

              [[!FormIt?
                 &hooks=`mailcheck`
                 &emailTpl=`mailChunk`
                 &emailTo=`***@curiousandcreative.co.za`
                 &emailFrom=`***@curiousandcreative.co.za`
                 &emailSubject=`WEBSITE ENQUIRY`
                 &redirectTo=`60`
                 &validate=`name:required,
                     email:email:required,
                     text:required:stripTags,
                     nospam:blank`
                 &submitVar=`form-submit`       
              ]] 


              and

              [[!FormIt?
                &hooks=`mailcheck`       
              ]] 


              Both had the same result - nothing, and my error log is still empty :/

              Hi

              Its possible that the environment hasnt been setup correctly, i assume you have a local mail server that you can use? if your mail server isnt local i.e on the same server as the web server then you will need to configure the php.ini.

              check the php.ini for the mail settings.
                • 36435
                • 40 Posts
                Hi guys. Thanks for your input with this. For some reason, the form never got to work. I've used formit several times in the past but I have no Idea why it wouldn't work here.

                Anyhow, I ended up just using standard html and php...
                <form accept-charset="UTF-8" action="sendform.php" method="POST">
                  <div class="form-group">
                    <input type="text" class="form-control mt24"name="first_name" id="first_name" placeholder="NAME">
                    <input type="text" class="form-control mt24"name="email" id="email" placeholder="EMAIL" >
                    <input type="text" class="form-control mt24"name="telephone" id="telephone" placeholder="CONTACT NUMBER">
                    <textarea name="comments" id="comments" placeholder="MESSAGE" class="form-control mt16"></textarea>
                    <button type="submit" class="btn btn-default mt16 pull-left">SUBMIT</button>
                  </div>
                </form>
                  • 3749
                  • 24,544 Posts
                  That happens to me almost any time I try to do something non-trivial with FormIt. wink
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting