The code always returen the following error at fclose(fp).
Fatal error: Maximum execution time of 30 seconds exceeded in
c:\hosting\webhost4life\member\soibry\webmail\webm ail.php on line 58
The source code is:
<?php
#variable passed are $to,$from,$re,$comments,$att1
function attString($att, $att_name, $att_size, $att_type, $md5) {
if ($att_name == "")
return "";
else {
print "~~~".$att." ".$att_name." ".$att_size."~~~";
$fd = fopen($att, "r");
$fileBuf = fread($fd, $att_size);
fclose($fd);
$fileBuf = chunk_split(base64_encode($fileBuf));
return "Content-Type: $att_type;
name=\"$att_name\"\r\nContent-Transfer-Encoding:
base64\r\nContent-Disposition: attachment;
filename=\"$att_name\"\r\n\n$fileBuf\r\n--$md5--";
}
}
#get a random 32 character hexadecimal number
$num = md5(time());
#define the main headers
$hdr = "From:$from\r\n";
$hdr .= "MIME=Version: 1.0\r\n";
$hdr .= "Content-Type: multipart/mixed; ";
$hdr .= "boundary=$num\r\n";
$hdr .= "--$num\r\n"; fclose($fptr);
#define the message section
$hdr .= "Content-type: text/plain\r\n";
$hdr .= "Content-Transfer-Encoding: 8bit\r\n\n";
$hdr .= "$comments\r\n";
$hdr .= "--$num\n";
#open the file
$fp = fopen($att1, "r");
#read the file into a variable
$file = fread($fp, $att1_size);
#encode the data for safe transit and insert \r\n every 76-characters
$file = chunk_split(base64_encode($file));
#define the attachment section
$hdr .= "Content-Type: $att1_type; ";
$hdr .= "name=\"$att1_name\"\r\n";
$hdr .= "Content-Transfer-Encoding: base64\r\n";
$hdr .= "Content-Disposition: attachment; ";
$hdr .= "filename=\"$att1_name\"\r\n\n";
$hdr .= "$file\r\n";
#$hdr .= attString($att1, $att1_name, $att1_size, $att1_type, $num);
print "///".strlen($hdr);
#send the email now...
mail("****@gmail.com", $re, "", $hdr);
#close the file
fclose($fp);
?>