<![CDATA[ Could not instantiate mail function. - My Forums]]> https://forums.modx.com/thread/?thread=46732 <![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=4#dis-post-544450 Had to tell the mailserver the new hosting/website IP.]]> fourroses666 Aug 24, 2016, 08:26 AM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=4#dis-post-544450 <![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=4#dis-post-479337 Quote from: tigrokon at Apr 07, 2013, 08:41 AM
As it was mentioned above formit also uses phpmailer class (/core/model/modx/mail/phpmailer/class.phpmailer.php)
The problem was with $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
(line 482). With $params variable. I just removed it and got everything work)

This just happened to me yesterday with no visible explanation. As you've seen, most answers have been vague at best, and hackish at worst. However, when I look at this code, it pointed me back to the
$modx->mail->set(modMail::MAIL_SENDER, $sender);
in my script, and when I check the value of $sender, sure enough it had a right-single-quote (’) in it. When I removed that, the class instantiated and worked fine.

So it seems that the problem isn't the $params variable above, the problem is not-so-good error logging in phpMailer (and not being able to accept utf8 characters?).]]>
dan971 Oct 02, 2013, 06:12 PM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=4#dis-post-479337
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=4#dis-post-462014 I got there when googling for the same issue ('Could not instantiate mail function' in error log) but now for MODX Revo's FormIt this time. As I see both cases have the same source of problem. So I will write here solution that worked for me.

As it was mentioned above formit also uses phpmailer class (/core/model/modx/mail/phpmailer/class.phpmailer.php)
The problem was with $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
(line 482). With $params variable. I just removed it and got everything work)]]>
tigrokon Apr 07, 2013, 08:41 AM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=4#dis-post-462014
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271136
http://bugs.modx.com/issues/3757

There is a complication, however. PHPMailer version 5.1 is for PHP 5/6. The version for PHP 4 is version 2.0.4]]>
sottwell Feb 07, 2011, 03:14 AM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271136
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271135 Quote from: dimecris at Jan 18, 2011, 11:50 AM

for me the solution was only to leave blank &to=`` This parameter is not necessary if you write an e-mail address in Tool/configuration/User. [...]
I tried this idea first (blank &to field). While the error message went away I still did not get the mail. I updated phpmailer to version 5.1 and now it works (Evo comes with 1.73 go figure)]]>
dorstox Feb 06, 2011, 07:37 PM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271135
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271134 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?
for me the solution was only to leave blank &to=`` This parameter is not necessary if you write an e-mail address in Tool/configuration/User. By default the eForm take this mail.
To resolve the problem you have to leave blank but dont forget to write it. Otherwise it wont work
[!eForm? &formid=`ContactUsForm` &subject=`` &to=`` &tpl=`eFeedBack` &report=`eFeedBackReport` &thankyou=`eFeedBackThanks` !]

After two days at the end it’s works
]]>
dimecris Jan 18, 2011, 05:50 AM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271134
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271133
http://modxcms.com/forums/index.php?topic=32969.0]]>
sottwell Jan 14, 2011, 04:44 AM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271133
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271132
Tried all the fixes suggested here; nothing worked.

has this been solved?]]>
danzg Jan 13, 2011, 02:21 PM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271132
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271131
I have the very same problem on an actual project and I just don’t know where the problem could be^^...tried your example with

<?php
$message = "Test 1\r\nTest 2\r\nTest 3";
mail('[email protected]', 'Testing mail function', $message);
echo $message;
?>


when I call it (named mail.php) there are no errors displayed but I don’t recieve an email...because of this I wrote to the hosting-support...tried also the \n to \r\n change (on line 223 in the phpmailer class), didn’t help, and then I tried also change on the else statement on line 438, also didn’t work...

this is somehow annoying, I have eform up and running on another project (different hosting) but this sould not happen, where is the root of this problem^^?


EDIT: I tried also to change the eform.inc to SMTP (look here: http://modxcms.com/forums/index.php/topic,36108.msg218125.html#msg218125), now I’m getting email =)...wtf]]>
exside Dec 05, 2009, 04:43 PM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271131
<![CDATA[Re: Could not instantiate mail function.]]> https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271130
tried the mail PHP scripts and they work fine.

anyone know a fix to what is going on here?]]>
bvandorp May 01, 2009, 04:52 AM https://forums.modx.com/thread/46732/could-not-instantiate-mail-function?page=3#dis-post-271130