We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7923
    • 4,213 Posts
    The snippet saving issue sounds like a mod_security thing.. is that on in your server environment? look at modx wiki for mod_security


      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • 30223
      • 1,010 Posts
      Quote from: sitesbycal at Apr 03, 2007, 10:54 PM

      Looking at my settings, it says that "safe_mode" is OFF

      Would that adversely affect this line:
      if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)


      I’ll look into the other things you mentioned too, thanks for helping me out. smiley



      You’re getting close.. I’ve done quite bit of googling on this error since reading this thread but sofar I see heaps of questions but no real answers... The problem seems to be triggered by the extra parameters in $params in the MailSend function (See post above for source). One solution I did see is to edit this function and manually set $params=’’; Be warned however! I have no experience with this myself and have no idea of any complications it might cause.
        • 27406
        • 12 Posts
        Does anyone know if I remove
        (ini_get("safe_mode"))

        will something bad happen to my server......

        I don’t know a heap about PHP and don’t want to remove something
        that’s probably there for a good reason......
        • All that line does is check the value of safe_mode, it neither sets nor unsets it.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 20744
            • 19 Posts
            Hi,

            I am getting the same error, "Could not instantiate mail function". I also tried to send mail from a basic PHP page and all seems fine, I receive the email. Did you manage to resolve the issue? If yes, could you let me know what it was?

            Thanks
              • 20744
              • 19 Posts
              Hi, I got this issue figured out. When adding the code to the page, the email address was automatically made an active mailto and that was messing up the code. My form seems to be working again and I don’t get the error on the php mail. I still haven’t managed to write the content to the database though. Any suggestions welcome...

              Thanks for all your help and suggestions.
                • 16989
                • 4 Posts
                Hi, I had the "could not instantiate" problem as well and after reading this thread here is what worked for me :-

                The simple php mail scripts worked ok.....

                In method MailSend in class.phpmailer.php:-

                if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)

                The object attribute "Sender" is blank so this portion of code is skipped (the safemode check appears to test whether safemode is not set - (it is set on my system so this skips even if I instantiated the Sender attribute in eform.inc.php)

                So I grabbed the sendmail_from parameter and used that in the else block

                else
                // amended lines added by CMD 15July08 needs a valid from address in mailto
                $old_from = ini_get("sendmail_from");
                $headers = ’From: ’ . $old_from . "\r\n" .
                ’Reply-To: ’ . $old_from . "\r\n" .
                ’X-Mailer: PHP/’ . phpversion();
                $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $headers);


                Ultimately my server didn’t like the format of the @mail call either in the initial ’If’ block or the ’else’ block and that reason is beyond my limited knowledge!
                  • 18878
                  • 210 Posts
                  Quote from: LesFragnes at Jul 15, 2008, 09:22 AM

                  Hi, I had the "could not instantiate" problem as well and after reading this thread here is what worked for me :-

                  The simple php mail scripts worked ok.....

                  In method MailSend in class.phpmailer.php:-

                  if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)

                  The object attribute "Sender" is blank so this portion of code is skipped (the safemode check appears to test whether safemode is not set - (it is set on my system so this skips even if I instantiated the Sender attribute in eform.inc.php)

                  So I grabbed the sendmail_from parameter and used that in the else block

                  else
                  // amended lines added by CMD 15July08 needs a valid from address in mailto
                  $old_from = ini_get("sendmail_from");
                  $headers = ’From: ’ . $old_from . "\r\n" .
                  ’Reply-To: ’ . $old_from . "\r\n" .
                  ’X-Mailer: PHP/’ . phpversion();
                  $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $headers);


                  Ultimately my server didn’t like the format of the @mail call either in the initial ’If’ block or the ’else’ block and that reason is beyond my limited knowledge!

                  Thanks a lot LesFragnes!, your way is the only way I could send mail with eform on IIS.
                    • 19962
                    • 1 Posts
                    I am having similar problems and receive the error message "Could not instantiate mail function" when email should get sent from this eform snippet

                    [!eForm? &formid=`ContactUsForm` &subject=`` &to=`info@myserver` &tpl=`eFeedBack` &report=`eFeedBackReport` &thankyou=`eFeedBackThanks` !]

                    I am led to think that my php mail setting is ok as I can run the test scripts listed on this thread successfully and receive those emails.

                    I think there is an issue somewhere with the handling of the "@" sign because when I change my snippet from "&to=`info@myserver`" to something without the at sign, for example "&to=`info`" the error message does not occur and the eFeedBackThanks gets displayed but of course this is not a proper email address so the email goes nowhere.

                    Any ideas for resolving this issue?



                      • 18878
                      • 210 Posts
                      Quote from: modman at Oct 04, 2008, 09:27 PM

                      I am having similar problems and receive the error message "Could not instantiate mail function" when email should get sent from this eform snippet

                      [!eForm? &formid=`ContactUsForm` &subject=`` &to=`info@myserver` &tpl=`eFeedBack` &report=`eFeedBackReport` &thankyou=`eFeedBackThanks` !]

                      I am led to think that my php mail setting is ok as I can run the test scripts listed on this thread successfully and receive those emails.

                      I think there is an issue somewhere with the handling of the "@" sign because when I change my snippet from "&to=`info@myserver`" to something without the at sign, for example "&to=`info`" the error message does not occur and the eFeedBackThanks gets displayed but of course this is not a proper email address so the email goes nowhere.

                      Any ideas for resolving this issue?


                      This is what I did in order to make it work for IIS.

                      In file: manager\includes\controls\class.phpmailer.php at line 438, I commented the line:
                      // $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header); 


                      and I added the following lines:
                      	{
                      		   $headers = 'From: [email protected]' . "\r\n" .
                                   'Reply-To: [email protected]' . "\r\n" .
                                   'X-Mailer: PHP/' . phpversion() . "\r\n" .
                      			 'MIME-Version: 1.0' . "\r\n" .
                      			 'Content-Transfer-Encoding: 8bit' . "\r\n" .
                      			 'Content-Type: text/html; charset="UTF-8"';
                      	       $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $headers);
                      		}

                      In my case there was no need to edit the php.ini file at all!

                      Hope it helps.

                      Regards.

                      Mc