Error with email attachment with size more than 2 MB
<p>I am trying to send email attatchment with size more than 2MB.But it give error 
<strong>"Fatal error: Allowed memory size of 31457280 bytes exhausted ".</strong>
I also tried the following </p>

<pre><code>memory_limit =30M
max_execution_time =3600 
post_max_size = 20M   
upload_max_filesize = 20M
</code></pre>

<p>in php.ini file.bt it doesn't work.</p>

<pre><code>&lt;?php
//sending Email using SMTP server
    include "phpmailer/class.smtp.php"; 
    include "phpmailer/class.phpmailer.php";

    $Host = "mail.gmail.com";                       // SMTP servers
    $Username = "YourEmail@gmail.com";  // SMTP password
    $Password = "******";                   // SMTP username

    $From = "YourEmail@gmail.com";
    $FromName = "Your Name";

    ////multilple mail id 
    $str =$_SESSION['MailAll'];

    $arr=explode(",",$str);
    $Tos=$arr;  

    $Ccs = array(
        "CC Name 1" =&gt; "cc-email-1@yahoo.com",
        "CC Name 2" =&gt; "cc-email-2@gmail.com"
    );

    $Subject ="Project Abstract";
    ///Message Body
    $Body =$_POST['mailcont'] ;;

    $mail = new PHPMailer();

    $mail-&gt;IsSMTP();                    // send via SMTP
    $mail-&gt;Host     = $Host; 
    $mail-&gt;SMTPAuth = true;             // turn on SMTP authentication
    $mail-&gt;Username = $Username;  
    $mail-&gt;Password = $Password; 

    $mail-&gt;From     = $From;
    $mail-&gt;FromName = $FromName;
    foreach($Tos as $key =&gt; $val){
        $mail-&gt;AddAddress($val , $key); 
    }


    $mail-&gt;WordWrap = 50;               // set word wrap
    $mail-&gt;Priority = 1; 
    $mail-&gt;IsHTML(true); 
///// Multiple attachment file pass to $arr by $str
    $str=$_SESSION['DOCFILE'];

    $arr=explode(",",$str);

  for($i=0;$i&lt;count($arr)-1;$i++){
     $mail-&gt;AddAttachment($arr[$i]);

}
    $mail-&gt;Subject  =  $Subject;
    $mail-&gt;Body     =  $Body;

     if(!$mail-&gt;Send())
    {
        echo "Mailer Error: " . $mail-&gt;ErrorInfo;
    }
    else
    {
      header('location:sendABS.php');
     //   echo 'Message has been sent.';
    }

?&gt;
</code></pre>
