function mail_attachment ($to, $subject, $message, $addr_from, $attachment,
$filename) {

        This function sends an e-mail with a file attachment using the
        PHP mail function with parameters $to, $subject and $message.
        The $attachment parameter is a string with the attachment file
content with
        filename $filename.

        $boundary = "b".md5(uniqid(time()));
        $mime = "From: $addr_from\n";
        $mime .= "Reply-To: $addr_from\n";
        $mime .= "X-Mailer: JOHN DOE\n";
        $mime .= "X-Sender: $addr_from\n";
        $mime .= "Content-type: multipart/mixed; ";
        $mime .= "boundary = $boundary\r\n\r\n";
        $mime .= "This is a MIME encoded message.\r\n\r\n";
        // First the regular message
        $mime .= "--$boundary\r\n";
        $mime .= "Content-type: text/plain\r\n";
        $mime .= "Content-Transfer-Encoding: base64";
        $mime .= "\r\n\r\n".chunk_split(base64_encode($message))."\r\n";
        // Now the attachment
        $mime .= "--$boundary\r\n";
        $mime .= "Content-type: text/plain\r\n";
        $mime .= "Content-Transfer-Encoding: base64\r\n";
        $mime .= "Content-Disposition: attachment; ";
        $mime .= "filename = ".chr(34).$filename.chr(34);
        $mime .= "\r\n\r\n".chunk_split(base64_encode($attachment))."\n";

        mail ($to, $subject, "", $mime);


Rudolf Visagie
Principal Software Developer
Digital Healthcare Solutions

-----Original Message-----
From: Krzysztof Kocjan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 4:49 PM
Subject: [PHP] Send mail and attachment with php - looking for PHP module


I'm looking for PHP module which allows to send mail and attachment 
both. Is there any one ? Thank You for any suggestions.


Muzyka dla Twoich uszu... >>>

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to