0

I have a script that sends an email at the end of work. At some point, stop sending messages with an error:

Could not instantiate mail function

No changes in the script or in the system settings have been made. The only thing that has changed - increased memory consumption and execution time as the increased volume of data being processed.

Could error associated with memory? If I try to send a message at the beginning of the script, everything works.

EDIT: The same code works at the beginning of the script and is doesn't work at the end.

    require_once 'class_phpmailer.php';

    $phpmail = new PHPMailer(); 
    $phpmail->CharSet = 'UTF-8'; 
    $phpmail->Sender = "my@site.com";
    $phpmail->From = "my@site.com";
    $phpmail->FromName = "mysite";
    $phpmail->AddAddress('another@site.com');
    $phpmail->Subject = 'test';
    $phpmail->MsgHTML('test');
    if( !$phpmail->Send() ){
        echo $phpmail->ErrorInfo ;  
    }
user451555
  • 185
  • 2
  • 11
  • This question has been asked [before](http://stackoverflow.com/questions/1944631/could-not-instantiate-mail-function-why-this-error-occuring), [here](http://stackoverflow.com/questions/1297084/phpmailer-error-could-not-instantiate-mail-function?lq=1) and [here](http://stackoverflow.com/questions/30648462/phpmailer-error-could-not-instantiate-mail-function?lq=1). Might want to check out duplicates. – Qirel Dec 03 '15 at 14:15
  • I read all the threads, the error is the same, but nothing similar to my case – user451555 Dec 03 '15 at 14:38
  • Just an idea, you never know :-) Don't think it's a memory-issue, most likely you would've gotten a specific error-message in that case. Perhaps sharing your code would help in troubleshooting. @user451555 – Qirel Dec 03 '15 at 14:42
  • I added code to my question – user451555 Dec 03 '15 at 16:12

1 Answers1

0

You can increase the php memory on runtime by adding this script at the top of your mailing page:

ini_set('memory_limit','16M');

Adjust the 16M

Martins
  • 430
  • 3
  • 11
  • Limit enough after an error the script is still running for some time and is completed without error associated with memory and execution time. – user451555 Dec 03 '15 at 14:34