开发者

Using pear : Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6144 bytes)

when i am trying to send a mail using PEAR, I got the following error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6开发者_开发百科144 bytes)

I am searched in this site, and found some solutions like

ini_set('memory_limit', '-1');

But I am getting the same error. Please help me...

<?php
    include('Mail.php');

    ini_set('memory_limit', '-1');
    $headers = array("From"=>"mymail@gmail.com", "Subject"=>"Test Mail");
    $body = "This is a test!";
    $mail = Mail::factory("mail");
    $mail->send("friend@example.com", $headers, $body);
?> 

Update

Actually I used the code : ini_set('memory_limit', '256M'); Because, when I looked into php.ini file, I found it was set as 128M. So i changed the value to 256M there and also in the code. But it didn't work. So i tried with 512M, and then finally with -1.

Thank you...


First, try setting memory_limit to 128M or something. Sending mail should not take that much memory, so if that doesn't work, there's probably something wrong in the Mail-class you're using. Are you sure you're using the latest version?

Besides that, what you're trying to accomplish can be easily done using native PHP:

mail("friend@example.com", "Subject", $body, implode($headers, "\r\n"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜