note 105661 added to function.mail
| From: | Anda at osu1 dot php dot net | Date: | Mon, 05 Sep 2011 18:57:37 +0000 |
| Subject: | note 105661 added to function.mail | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182958@lists.php.net to get a copy of this message | ||
Send Multi attachment email
<?php
function multi_attach_mail($to, $files, $sendermail){
// email fields: to, from, subject, and so on
$from = "Files attach <".$sendermail.">";
$subject = date("d.M H:i")." F=".count($files);
$message = date("Y.m.d H:i:s")."\n".count($files)." attachments";
$headers = "From: $from";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "--{$mime_boundary}\n" . "Content-Type: text/plain;
charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
// preparing attachments
for($i=0;$i<count($files);$i++){
if(is_file($files[$i])){
$message .= "--{$mime_boundary}\n";
$fp = @fopen($files[$i],"rb");
$data = @fread($fp,filesize($files[$i]));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream;
name=\"".basename($files[$i])."\"\n" .
"Content-Description: ".basename($files[$i])."\n" .
"Content-Disposition: attachment;\n" . "
filename=\"".basename($files[$i])."\";
size=".filesize($files[$i]).";\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
}
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $sendermail;
$ok = @mail($to, $subject, $message, $headers, $returnpath);
if($ok){ return $i; } else { return 0; }
}
?>
----
Server IP: 92.48.119.85
Probable Submitter: 188.112.160.234
----
Manual Page -- http://www.php.net/manual/en/function.mail.php
Edit -- https://master.php.net/note/edit/105661
Del: integrated -- https://master.php.net/note/delete/105661/integrated
Del: useless -- https://master.php.net/note/delete/105661/useless
Del: bad code -- https://master.php.net/note/delete/105661/bad+code
Del: spam -- https://master.php.net/note/delete/105661/spam
Del: non-english -- https://master.php.net/note/delete/105661/non-english
Del: in docs -- https://master.php.net/note/delete/105661/in+docs
Del: other reasons-- https://master.php.net/note/delete/105661
Reject -- https://master.php.net/note/reject/105661
Search -- https://master.php.net/manage/user-notes.php