note 27020 deleted from ref.mail by vincent

From: Date: Fri, 12 Sep 2003 06:53:46 +0000
Subject: note 27020 deleted from ref.mail by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56328@lists.php.net to get a copy of this message
Note Submitter: hilger at emotiv-design dot de ---- attachments in mail function I just wanted to add something useful to Kieran's note (06-Nov-2002 10:52): you can automate the attachment by reading the file into a variable with fopen and fread, then (important) base64_encode it and chunksplit it. It worked fine with all PDFs I tried - the attachment just gets a little bigger (around 35%). In the example below I used Kierans script, but shortened it in some places. HTML version etc. can of course be added again. $headers = "From: $from <$email>\n"; $headers .= "Reply-To: $from <$email>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"MIME_BOUNDRY\"\n"; $headers .= "X-Sender: $from_k <$email>\n"; $headers .= "X-Mailer: PHP4\n"; $headers .= "X-Priority: 3\n"; $headers .= "Return-Path: <$email>\n"; $headers .= "This is a multi-part message in MIME format.\n"; $message = "--MIME_BOUNDRY\n"; $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $message .= "Content-Transfer-Encoding: quoted-printable\n"; $message .= "\n"; // your text goes here $message .= "blah blah -- plaintext version of the message\n"; $message .= "\n"; $message .= "--MIME_BOUNDRY\n"; $message .= "Content-Type: application/pdf; name=\"brilliant.pdf\"\n"; $message .= "Content-disposition: attachment\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "\n"; $message .= "$str\n"; $message .= "\n"; //message ends $message .= "--MIME_BOUNDRY--\n";

« previous php.notes (#56328) next »