note 50876 added to ref.mail

From: Date: Sat, 12 Mar 2005 16:16:56 +0000
Subject: note 50876 added to ref.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-86327@lists.php.net to get a copy of this message
May I know wat is the problem in my code ???? I 'm totally a beginner in PHP.. <?php $boundary = '-----=' . md5( uniqid ( rand() ) ); ?> You can attach a Word document if you specify: &nbsp;&nbsp;&nbsp; <?php $theFile = "monk4.jpg"; $message ="hi\n"; $message .= "Content-Type: application/msword; name= my attachment \n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$theFile\"\n\n"; ?> When adding a file you must open it and read it with fopen and add the content to the message:&nbsp;&nbsp;&nbsp;<br><br><br> <?php $content = ""; $path = "c:\monk4.jpg"; $fp = fopen($path, 'r'); do { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; ?> Add the needed headers and send!&nbsp;&nbsp;&nbsp;<br><br><br> <?php /* $headers = "From: reliC\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; */ ?> Finally, if you add an image and want it displayed in your email, change the Content-Type from attachment to inline:<br><br><br><br> <?php $message .= "Content-Disposition: inline; filename=\"$theFile\"\n\n"; mail("smartcare@smartcare.com", "test SMTP with Attachment", $message); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.mail.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50876 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50876&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50876&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50876&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50876&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50876&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50876&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86327) next »