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

    I’ve built a feedback form with eForm but am getting the following message on submission of the mail:
    Main mail: Mailer was unable to send mailCould not instantiate mail function.

    Here’s how the call looks in the page template:
    [!eForm? &formid=`ContactForm` &to=`[email protected]` &tpl=`eContactForm` &report=`eContactForm-Report` &thankyou=`eThanksMessage` &subject=`Response from feedback form` &from=`[+email+]`!]

    I feel i’ve done everything right (apparently not!) eg: created the template with all the chunk calls and have checked they are spelt/named correctly etc. and i’m pretty sure that the chunks are all correctly formed.

    Can anyone advise here?
    Thanks in advance
      • 7231
      • 4,205 Posts
      It looks like you may not have the mail() function available in your PHP setup. If you are on a remote server contact your hosting support an ask if this is true. If on a local setup sometimes these tools are disabled by default.

        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 21257 MODX Staff
        • 730 Posts
        I wonder if there’s a misconfiguration in your server’s PHP, or if the server lacks the mechanism to send mail.

        eform uses the phpmailer class to send mail. While it is a fairly capable mail library (it can send mail via 3 different mechanisms - SendMail, SMTP or PHP’s native mail function), eform only utilizes the PHP native mail mechanism. I have a few server configurations where PHP can’t send mail using it’s default mail function. This can occur for various reasons. I’m not a mail expert at all, so I can’t go into detail about it. But I do know that on these servers, when I send mail from my php code, I have to use a library like phpmailer or Swift to send via SMTP. Then it works fine.

        You could try running a little php script like this to isolate and test php’s native mail function:
        <?php
        echo mail('[email protected]', 'test subject', 'test mail body');
        
        

        If you put that script on your server, call it "mailtest.php" or something, then call it up in your browser, you should see the script output the number 1 and nothing else (and you should get the test email delivered to the email address in the script). If it outputs 0 or anything other than 1, then the mail function did not work due to configuration or something.
          Mike Schell
          Lead Developer, MODX Cloud
          Email: [email protected]
          GitHub: https://github.com/netProphET/
          Twitter: @mkschell
          • 25519
          • 265 Posts
          Hi and thanks for the replies
          I ran the tesmail.php script and it worked fine - got output 1 and the mail went to the designated mailbox.

          The site is running on a 1and1 server, but i’m using eForm in a different modx site also on a 1and1 server and it worked fine. Wierd thing is that I transposed an exact copy of the working 1and1 eForm onto the non-working site and that also gave the same instantiation error, which would imply the server php config causing the problem ... but it is the same server ...

          Is there any other way to root out any other problems via searching phpinfo?

          Thanks again

            • 7231
            • 4,205 Posts
            If the mail() is working then one of the parameters is not being set correctly when eForm is trying to send the message. It could be something that is breaking the strings in an odd place. Are there any backticks or quotes (single or double) in your report chunks?

              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 25519
              • 265 Posts
              No, I checked all chunks thoroughly and they look fine - essentially I have re-used a form on another site which works perfectly (on the same server model) and made the necessary adjustments. I could pm the phpinfo address if this would help.

              Thanks
                • 7231
                • 4,205 Posts
                I could pm the phpinfo address if this would help.
                Sorry, but I don’t think I would be able to identify something in the phpinfo output.

                It is odd since the mail() seams to be working. Are you sending in HTML or in text format?

                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 25519
                  • 265 Posts
                  Sorry for the late reply
                  I guess the reply is in html format - i’ve followed the eForm example page which comes with the download.

                  This is an odd one as I’ve completely duplicated a working form which runs on the same server model into this site for testing and i’m getting the same instantiation problem. Do you think this is a server issue or something within the site conflicting with eForm?

                  Thanks