我尝试使用附件.zip或.rar文件发送邮件,但我无法发送超过1mb的文件。
$to ="jignesh.tplabs@gmail.com";
$fromEmail = $_POST['email'];
$subject = $_POST['name'];
/* GET File Variables */
$tmpName = $_FILES['attachment']['tmp_name'];
$fileType = $_FILES['attachment']['type'];
$fileName = $_FILES['attachment']['name'];
/* Start of headers */
$headers = "From: $fromEmail ";
if (file($tmpName)) {
/* Reading file ('rb' = read binary) */
$file = fopen($tmpName,'r');
$data = fread($file,filesize($tmpName));
fclose($file);
/* a boundary string */
$randomVal = md5(time());
$mimeBoundary = "==Multipart_Boundary_x{$randomVal}x";
/* Header for File Attachment */
$headers .= "\nMIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;\n" ;
$headers .= " boundary=\"{$mimeBoundary}\"";
/* Multipart Boundary above message */
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mimeBoundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
// $message . "\n\n";
/* Encoding file data */
$data = chunk_split(base64_encode($data));
/* Adding attchment-file to message*/
$message .= "--{$mimeBoundary}\n" .
"Content-Type: {$fileType};\n" .
" name=\"{$fileName}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mimeBoundary}--\n";
}
$ flgchk = mail(“$ to”,“$ subject”,“$ message”,“$ headers”);
如果($ flgchk){ echo“alert('Mail Sent'); window.location.href ='index.html';”; } 其他{ echo“alert('Mail Sending Failed。'); history.back();”; }
答案 0 :(得分:0)
TSUP。这可能会有所帮助。 将数据块化为1MB并启动php邮件功能,每1分钟发送1 MB(睡眠时间为$ $秒)。
此外,您需要知道托管服务提供商在php.ini文件中提供的最长执行时间的值是多少。
在本网站链接中有很好的解释。看看吧。
http://forums.phpfreaks.com/topic/278251-php-mail-attachment-max-size