Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message)
- {
- $file = $path.$filename;
- $file_size = filesize($file);
- $handle = fopen($file, "r");
- $content = fread($handle, $file_size);
- fclose($handle);
- $content = chunk_split(base64_encode($content));
- $uid = md5(uniqid(time()));
- $name = basename($file);
- $header = "From: ".$from_name." <".$from_mail.">rn";
- $header .= "Reply-To: ".$replyto."rn";
- $header .= "MIME-Version: 1.0rn";
- $header .= "Content-Type: multipart/mixed; boundary="".$uid.""rnrn";
- $header .= "This is a multi-part message in MIME format.rn";
- $header .= "--".$uid."rn";
- $header .= "Content-type:text/plain; charset=iso-8859-1rn";
- $header .= "Content-Transfer-Encoding: 7bitrnrn";
- $header .= $message."rnrn";
- $header .= "--".$uid."rn";
- $header .= "Content-Type: application/octet-stream; name="".$filename.""rn";
- // use different content types here
- $header .= "Content-Transfer-Encoding: base64rn";
- $header .= "Content-Disposition: attachment; filename="".$filename.""rnrn";
- $header .= $content."rnrn";
- $header .= "--".$uid."--";
- mail($mailto, $subject, $message, $header);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement