المميزات:
إرفاق الملف سريع
يمكن عمل include
كود:
<?
Function mailattachments( $to, $subject, $body, $attacharray,
$extraheaders)
{
// Generate a unique boundary
$mail_boundary = md5(uniqid(time()));
// MIME-compliant headers
$mailheaders = $extraheaders
."MIME-Version: 1.0\r\n"
."Content-type: multipart/mixed;boundary=\"$mail_boundary\"\r\n"
."\r\n"
."This is a multipart MIME message\r\n"
."\r\n";
// Body. The part that gets displayed as the message:
$mailbody = "--$mail_boundary\r\n"
."Content-type: text/plain;charset=us-ascii\r\n"
."Content-transfer-encoding: 8bit\r\n"
."\r\n"
.$body
."\r\n";
// Now, do the attachments
for ($i = 0; $i < count($attacharray); $i++ )
{
$fp = fopen($attacharray[$i][filename], "r");
$file = fread($fp, filesize($attacharray[$i][filename]));
$file = base64_encode($file); // BASE64-encoded.
Text. Nice.
$file = chunk_split($file); // Now in handy
bite-sized 76-char chunks.
$filename = basename($attacharray[$i][filename]);
$mailbody .= "--$mail_boundary\r\n"
."Content-type: ".$attacharray[$i][mimetype]."; name=".$filename."\r\n"
."Content-transfer-encoding: base64\r\n"
."\r\n"
.$file
."\r\n"
."\r\n";
}
// End of mail
$mailbody .= "--$mail_boundary--";
mail($to, $subject, $mailbody, $mailheaders);
}
?>
دعواتكم