我尝试发送带有附件.zip或.rar文件的邮件,但我不能发送超过1mb的文件。
$to ="[email protected]";
$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 =邮件(“ $ to”,“ $ subject”,“ $ message”,“ $ header”);
if($ flgchk){echo“ alert('Mail Sent'); window.location.href ='index.html';”; } else {echo“ alert('邮件发送失败。'); history.back();”; }
tsup。这可能会有帮助。将数据分块到1MB并启动php邮件功能以每1分钟发送1 MB的睡眠时间(int $ seconds)。
另外,您需要知道php.ini文件中主机提供商所提供的最大执行时间的值是多少。
在此网站链接中对此进行了很好的解释。一探究竟。
http://forums.phpfreaks.com/topic/278251-php-mail-attachment-max-size
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句