我是新用的PHP邮件,我试图发送至少1.5 Mb的附件,但它不起作用,但对于小尺寸的图像,它的工作原理。我已经将php.ini配置为更高的值,如upload_max_filesize,post_max_size,max_execution_time和max_input time。但仍然没有任何作用。我一直在网上搜索一些答案,但仍然没有可能的解决方案。谁能帮我?提前谢谢你
<?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();
?>
答案 0 :(得分:0)
在php.ini中设置upload_max_filesize和post_max_size的值:
上传文件的最大允许大小。
upload_max_filesize = 40M
必须大于或等于upload_max_filesize
post_max_size = 40M
答案 1 :(得分:0)
您是否检查了收件人的邮箱大小限制,附件限制以确保您发送的邮件是否在限制范围内?
http://en.wikipedia.org/wiki/Comparison_of_webmail_providers