RE: [PHP] sending mail with pdf attachment

From: Date: Thu, 17 Apr 2003 15:53:15 +0000
Subject: RE: [PHP] sending mail with pdf attachment
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144316@lists.php.net to get a copy of this message
Here is the function I have been using works like a charm just set the type to "multipart/mixed" function sendmsg($to, $subject, $text, $from, $file, $type) { $content = fread(fopen($file,"r"),filesize($file)); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time()))); $name = basename($file); $header = "From: $from\nReply-To: $from\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-Type: multipart/mixed; boundary=$uid\n"; $header .= "--$uid\n"; $header .= "Content-Type: text/plain\n"; $header .= "Content-Transfer-Encoding: 8bit\n\n"; $header .= "$text\n"; $header .= "--$uid\n"; $header .= "Content-Type: $type; name=\"$name\"\n"; $header .= "Content-Transfer-Encoding: base64\n"; $header .= "Content-Disposition: attachment; filename=\"$name\"\n\n"; $header .= "$content\n"; $header .= "--$uid--"; mail($to, $subject, "", $header); return true; } Thank You Brian Paulson Sr. Web Developer Email: Bpaulson@Chieftain.com Phone: 1-800-279-6397 Fax: 1-719-544-0264 URL: www.chieftain.com ------------------------------------------- -----Original Message----- From: Merlin [mailto:news.groups@web.de] Sent: Thursday, April 17, 2003 8:48 AM To: php-general@lists.php.net Subject: [PHP] sending mail with pdf attachment Hi there, I would like to send email with php mail function incuding a pdf attachment. After playing around with it and several searches on google I am stuck. The mail is delivered, and the attachment contains plain text (the message). Maybe someone can give me a small hint. I guess it can't be that hard to send an pdf attachment ??!! Thanx, Merlin // send mail with attachment function my_mail3($to,$subject,$message,$from){ $mailHeaders = "From: ".$from."\n"; // from $mailHeaders .= "X-Mailer: PHP\n"; // mailer $mailHeaders .= "Return-Path: <".$from.">\n"; // Return path for errors $mailHeaders .= "MIME-Version: 1.0\r\n"; $mailHeaders .= "Content-Type: application/pdf; name=test.pdf; Content-Disposition: attachment; Content-Transfer-Encoding: quoted-printable\r\n"; #$headers .= "X-Attach my_file_path"; $body = $message; if (mail($to, $subject, $body, $mailHeaders) ){ return true; } else{ return false; }; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#144316) next »