We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10525
    • 247 Posts
    Hi folks,

    I am trying to solve this issue and now after 2 days going round in circles.

    I'm using:
    formit: 2.2.5-pl
    modx: 2.3.3
    Plesk: 12.0.18
    CentOS 6.6
    Postfix 2.8.17-14042513

    When I fill out my form and click send, the form page is redisplayed with input content still there and the error message:

    "An error occurred while trying to send the email. Could not instantiate mail function."

    If I try to send the form blank, or with any combination of incorrect input content I get all the validation error messages as expected. So at this level, FormIt is acting normally.

    I tried this simplified version of the form and get the same error:
    [[!FormIt?
        &hooks=`email`
        &submitVar=`contactUsFormSubmit`
        &emailTpl=`contactEmailFormIt`
        &emailTo=`me@my_gmail.com`
        &emailFrom=`me@my_other_email.com`
        &emailFromName=`Gav`
        &emailSubject=`My formit test`
        &successMessage=`message sent!`
    ]]
    
      
    <form id="contactUsForm" action="[[~[[*id]]]]" method="post">
    
    	[[!+fi.error_message:notempty=`<p>[[!+fi.error_message]]</p>`]]
    	[[!+fi.validation_error_message]]
        	
    	<div class="formRow">			    
    		<label for="name">Name:</label>			    
    		<input type="text" name="name" id="name" value="[[!+fi.name]]" />				
    	</div>
                  
    	<button type="submit" value="Send" name="contactUsFormSubmit">Send Message</button>
    </form>

    My mail forms worked prior to a server move, so this is likely to be a server config thing. However, modx and formit have also been updated and I need to ensure they are configured properly too.

    I have tested mail sending from the server with the following script (php file in the web root, not within modx):
    <?php 
        ini_set( 'display_errors', 1 );
        error_reporting( E_ALL );
        $from = "me@my_domain.com";
        $to = "me@my_gmail.com";
        $subject = "PHP Mail Test script";
        $message = "This is a test to check PHP Mail functionality";
        $headers = "From:" . $from;
        mail($to,$subject,$message, $headers);
        echo "Test email sent";
    ?>

    This works and the email is received.

    So I need to know what I have to check, test and reconfigure, in MODx/Plesk/server, to diagnose and make this work.

    Any suggestions as to how I should proceed?



    EDIT: Running this in SSH successfully sends an email to my gmail:
    echo "Test mail from postfix" | mail -s "Test Postfix" me@my_gmail.com
    So Postfix is working.
    I suspect it's a FormIt setting that I need to change?.... [ed. note: Gav last edited this post 8 years, 10 months ago.]
      • 10525
      • 247 Posts
      Here are my modx settings:

      Namespace: core, Area: Mail

      mail_charset : UTF-8
      mail_encoding : 8bit
      mail_use_smtp :
      mail_smtp_auth : 0
      mail_smtp_helo :
      mail_smtp_hosts localhost :
      mail_smtp_keepalive :
      mail_smtp_pass :
      mail_smtp_port : 587
      mail_smtp_prefix :
      mail_smtp_single_to :
      mail_smtp_timeout : 10
      mail_smtp_user :


      Namespace: formit

      formit.exclude_contexts : mgr
      formit.recaptcha_private_key :
      formit.recaptcha_public_key :
      formit.recaptcha_use_ssl :
        • 50150
        • 6 Posts
        ok, well you need to change some of those system settings. I only found your post whilst trying to resolve a similar issue, but I know that you need to fill in many of those. Try these settings.

        mail_charset : UTF-8
        mail_encoding : 8bit
        mail_use_smtp : Yes
        mail_smtp_auth : Yes
        mail_smtp_helo :
        mail_smtp_hosts : smtp.gmail.com
        mail_smtp_keepalive: No
        mail_smtp_pass : yourgmailpasswordgoeshere
        mail_smtp_port : 587
        mail_smtp_prefix: tls
        mail_smtp_single_to: No
        mail_smtp_timeout: 10
        mail_smtp_user : [email protected]
          • 23510
          • 168 Posts
          Hi, I have this same problem when trying to use the FormItAutoResponder hook. The funny thing is if I remove the hook, an email (a notification to the admin) is sent just fine, so I am not sure the problem is with my settings.
            • 37105
            • 194 Posts
            Maybe you give QuickEmail extra by Bob Ray a try? http://modx.com/extras/package/quickemail
            It's main purpose is to diagnose email handling within MODX.

            And as Isaac1 says, setting SMTP could be a solution. Many hosters only allow to use mailer function when using existing e-mailaddress from that host.
              Codeplaza Webdesign: for professional websites at low cost
              • 47401
              • 295 Posts
              modx should send an email out without messing around with any settings. It sounds to me like its smtp settings in the php.ini file on your hosting. if your using WHM or Cpannel you will have access to this.
                • 3749
                • 24,544 Posts
                Make sure *all* the email addresses you use when testing are real. Servers often balk when they see a bogus email address like [email protected].
                  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