1

I'm new using php mail and I was trying to send an attachment with at least 1.5 Mb but it doesn't work, but for small size images it works. I've already configure my php.ini to higher values like upload_max_filesize, post_max_size, max_execution_time and max_input time. but still nothing works. I've been searching the net for some answers but still no possible solution. Can Anyone help me? thank you in advance

<?php

    /* Set e-mail recipient */
    $myemail = "test@yahoo.com";



    //*** Get values form fields ***//
    $contact = $_POST['contact'];
    $strtitle = $_POST["txtSubject"];
    $type = $_POST['type'];
    $message = $_POST['txtDescription'];
    $message = wordwrap($message, 70);

    $message = "

                    <b> Contact No:</b>  $contact <br><br>


                        <b>Description:</b><br>
                        $message <br>

                        <b>Type</b> : $type


                ";

    //*** Uniqid Session ***//
    $strSid = md5(uniqid(time()));

    $strHeader = "";

    $strHeader .= "MIME-Version: 1.0\n";
    $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
    $strHeader .= "This is a multi-part message in MIME format.\n";

    $strHeader .= "--".$strSid."\n";
    $strHeader .= "Content-type: text/html; charset=utf-8\n";
    $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
    $strHeader .= $message."\n\n";





    // *** Attachment ***//

    if($_FILES["fileAttach"]["name"] != "")
    {
        $strFilesName = $_FILES["fileAttach"]["name"];
        $strFileName = ($_FILES["fileAttach"]["size"]  < 1000000);
        $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"]))); 
        $strHeader .= "--".$strSid."\n";
        $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n"; 
        $strHeader .= "Content-Transfer-Encoding: base64\n";
        $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";

         $strHeader .= $strContent."\n\n";
    }


    $flgSend = @mail($myemail,$strtitle,null,$strHeader);  // @ = No Show Error //

    if($flgSend)
    {
        echo "<script type='text/javascript'>
                                    alert('Report Successfully Sent');window.location.href='Bug.php';
                                </script>"; 

        // echo "Size: " . ($_FILES["fileAttach"]["size"]);

    }
    else

    //Alert when Cannot connect to server
    {
        echo "<script type='text/javascript'>
                                    alert('Report Failed to Send : Server Connection Timed Out');window.location.href='Bug.php';
                                </script>";

        // echo "Size Failed: " . ($_FILES["fileAttach"]["size"]);

    }


exit();







?>
krish
  • 221
  • 1
  • 4
  • 20
user3213861
  • 125
  • 1
  • 2
  • 10

2 Answers2

0

to set the value of upload_max_filesize and post_max_size in your php.ini :

Maximum allowed size for uploaded files.

upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize

post_max_size = 40M

check this question PHP change the maximum upload file size

Community
  • 1
  • 1
krish
  • 221
  • 1
  • 4
  • 20
  • Hi krish, I've already set the values like you said but still no luck. any possible reasons why I can't upload large files? – user3213861 Feb 04 '14 at 07:18
0

Have you checked the recipient's mail box size limit, attachment limit to ensure the mail you are sending falls within the limit?

http://en.wikipedia.org/wiki/Comparison_of_webmail_providers

Tan Hong Tat
  • 6,671
  • 2
  • 27
  • 25