We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Quote from: Muggins at Sep 16, 2010, 11:59 AM

    I too have this problem and have tried various solutions - is there a conclusive reason for the message "An error occurred while trying to send the email."

    Thanks

    That usually means the host has mail() turned off. Use the SMTP settings in System -> System Settings or the SMTP parameters in FormIt -- *but not both* -- to send from an SMTP account you have somewhere (e.g., Gmail).
      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
      • 3866 ☆ A M B ☆
      • 350 Posts
      Have checked with hosts who assure me that mail() function is enabled and yet I’m still having problem getting FormIt to work. Have tried the sample documentation in the ADDON documentation without any joy - did wonder if there was some sort of conflict with TinyMCE? Noticed that when code is checked in html the & is changed to & does this make a difference?
      Will continue trying tomorrow.
      Thanks for response.
        Helen Warner
        Number one pixel!
        Proud to be linked with MODX at Crimson Pixel
        • 3749
        • 24,544 Posts
        Try this in a snippet (change the address in the first line to your email address):

        <?php
        $to = "[email protected]";
        $subject = "Test mail";
        $message = "Hello! This is a simple email message.";
        $from = "[email protected]";
        $headers = "From: " .  $from;
        mail($to,$subject,$message,$headers);
        return "Attempted Mail Send.";
        ?> 


        If you get the mail, mail() is working.
          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
          • 3866 ☆ A M B ☆
          • 350 Posts
          I’ve run the snippet in last post and received the mail, so thats clarified that at least - now I will have to look closer at my form and call!

          This is my call
          [[!FormIt? &hooks=`email,redirect` &emailSubject=`Enquiry` &emailTpl=`emailResponse` &emailTo=`[email protected]` &redirectTo=`8`]]

          And this is the form
          [[+fi.error.error_message]]
          <fieldset>
          <form id="EmailForm" action="[[~[[*id]]]]" method="post">
          <input name="nospam:blank" type="hidden" />

          <h3>Your Details</h3>

          <label class="label" for="Name">Your name:</label>
          <input id="name" name="name:required" size="40" type="text" value="[[+fi.name]]" />
          <span class="error">[[+fi.error.name]]</span>


          <label class="label" for="Address">Address:</label>
          <textarea id="address1" cols="20" rows="4" name="address"></textarea>


          <label class="label" for="Postcode">Postcode: </label>
          <input id="code" name="postcode:required" size="30" type="text" value="[[+fi.postcode]]" />
          <span class="error">[[+fi.error.postcode]]</span>


          <label class="label" for="Phonenumber">Contact Number:</label>
          <input id="phone" name="phone:required" size="40" type="text" value="[[+fi.phone]]" />
          <span class="error">[[+fi.error.phone]]</span>


          <label class="label" for="Email">Your Email Address:</label>
          <input id="email" name="email:email:required" type="text" value="[[+fi.email]]" />
          <span class="error">[[+fi.error.email]]</span>

          <hr />

          <h3>Enquiry Details</h3>
          <label class="label" for="subject">Please select subject:</label>
          <select id="subject" name="subject">
          <option value="None">--Select subject--</option>
          <option value="Property Owner">Property Owner</option>
          <option value="Advertising Opportunity">Advertising</option>
          <option value="General">General</option>
          </select>


          <div id="message">
          <label class="label" for="Message">Message: </label>
          <textarea id="message" cols="20" rows="4" name="message"></textarea>
          </div>


          <input id="enquire" class="button" name="Enquire" type="submit" value="Send Enquiry" />
          </form>
          </fieldset>

          Is there something wrong with my code?
            Helen Warner
            Number one pixel!
            Proud to be linked with MODX at Crimson Pixel
            • 1778
            • 659 Posts
            Hello

            As far as I can see in your posted code you have :
            <fieldset>
              <form>
                // here the content of your form...
              </form>
            </fieldset>
            


            Maybe I’m wrong on this but I guess the ’fieldset’ should be into the ’form’ (a fieldset is a part of a form)., something like:
            <form>
              <fieldset>
                 <!-- a group of fields here (ie: identity) -->
              </fieldset>
              <fieldset>
                 <!-- another group of fields here (ie: address) -->
              </fieldset>
            </form>
            


            Hope this helps
            Cheers
              • 3866 ☆ A M B ☆
              • 350 Posts
              grin Majorly happy, managed to get FormIt working!

              Re-installed FormIt and then used the example in documentation and that worked - cool! Next was to clean up my own form using the example as a basis and so below is the code I used which finally worked for me.
              [[!FormIt? &amp;hooks=`spam,email,redirect` &amp;emailSubject=`Enquiry` &amp;emailTpl=`emailResponse` &amp;emailTo=`[email protected]` &amp;redirectTo=`8`]]
              <p>[[+fi.error.error_message]]</p>
              <form id="EmailForm" action="[[~[[*id]]]]" method="post">
              <input name="nospam:blank" type="hidden" />
              <h3>Your Details</h3>
              <label for="Name">Your name:<span class="error">[[+fi.error.name]]</span></label>
              <input id="name" name="name:required" type="text" value="[[+fi.name]]" />
              <label for="Address">Address:</label>
              <textarea id="address1" cols="20" rows="4" name="address"></textarea>
              <label for="Postcode">Postcode:<span class="error">[[+fi.error.postcode]]</span></label>
              <input id="code" name="postcode:required" type="text" value="[[+fi.postcode]]" />

              <label for="Phonenumber">Contact Number:<span class="error">[[+fi.error.phone]]</span></label>
              <input id="phone" name="phone:required" type="text" value="[[+fi.phone]]" />

              <label for="Email">Your Email Address:<span class="error">[[+fi.error.email]]</span></label>
              <input id="email" name="email:email:required" type="text" value="[[+fi.email]]" />
              <h3>Enquiry Details</h3>
              <label for="subject">Please select subject:</label>
              <select id="subject" name="subject">
              <option value="None">--Select subject--</option>
              <option value="Property Owner">Property Owner</option>
              <option value="Advertising Opportunity">Advertising</option>
              <option value="General">General</option>
              </select>
              <div id="message">
              <label for="Message">Message: <span class="error">[[+fi.error.message]]</span></label>
              <textarea id="message" cols="55" rows="7" name="message:required:stripTags">[[+fi.message]]</textarea>
              </div>
              <input id="enquire" type="submit" value="Send Enquiry" />
              </form>

              Thanks for help - on to next headache! laugh
                Helen Warner
                Number one pixel!
                Proud to be linked with MODX at Crimson Pixel
                • 3749
                • 24,544 Posts
                Glad you got it sorted. smiley

                Thanks for reporting back.
                  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
                  • 3866 ☆ A M B ☆
                  • 350 Posts
                  I had a request for the chunk `emailresponse` that I’ve used with my formit call and thought others may wish to share, so here is the chunk I used - very simple

                  Message from website


                  [[+name]] ([[+email]]) wrote:
                  [[+subject]]

                  [[+message]]

                  Address: [[+address]]
                  Post Code: [[+postcode]]

                  Contact Number:[[+phone]]
                    Helen Warner
                    Number one pixel!
                    Proud to be linked with MODX at Crimson Pixel
                    • 23889
                    • 11 Posts
                    Hello

                    I am using following code...Its not working....Giving no error n not sending mail..
                    Plz help ASAP


                    <h2 class="enq">ENQUIRY FORM</h2>
                    [[!FormIt?
                    &hooks=`recaptcha,spam,email,redirect`
                    &emailTpl=`MyEmailChunk`
                    &emailTo=`[email protected]`
                    &redirectTo=`6`
                    &validate=`name:required,
                    email:email:required,
                    subject:required,
                    text:required:stripTags,

                    ]]


                    [[!+fi.error.error_message:notempty=`<p>[[!+fi.error.error_message]]</p>`]]

                    <form action="[[~[[*id]]]]" method="post" class="form">

                    <input type="hidden" name="nospam:blank" value="" />
                    <table>
                    <tr>
                    <td><label for="name">Name:</label></td>
                    <td>
                    <input type="text" name="name" id="name" value="[[+fi.name]]" />
                    <span class="error">[[+fi.error.name]]</span>
                    </td>
                    </tr>

                    <tr>
                    <td><label for="email">Email:</label></td>
                    <td>
                    <input type="text" name="email" id="email" value="[[+fi.email]]" />
                    <span class="error">[[+fi.error.email]]</span>
                    </td>
                    </tr>

                    <tr>
                    <td><label for="subject">Subject:</label></td>
                    <td>
                    <input type="text" name="subject" id="subject" value="[[+fi.subject]]" />
                    <span class="error">[[+fi.error.subject]]</span>
                    </td>
                    </tr>


                    <tr>
                    <td><label for="text">Message:</label></td>
                    <td>
                    <textarea name="text" id="text" cols="40" rows="7" value="[[+fi.text]]">[[+fi.text]]</textarea>
                    <span class="error">[[+fi.error.text]]</span>
                    </td>
                    </tr>






                    <td></td>
                    <td>
                    <div class="form-buttons">
                    <input type="submit" value="Send Contact Inquiry" />
                    </div>
                    </td>
                    </table>
                    </form>


                      • 3749
                      • 24,544 Posts
                      Before going any further, I’d recommend downloading the QuickEmail package through Package Manager to make sure that your email system is working.
                        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