Here is a function I use that might help:
function mail_attachment ($to, $subject, $message, $addr_from, $attachment,
$filename) {
/*
This function sends an e-mail with a file attachment using the
standard
PHP mail function with parameters $to, $subject and $message.
The $attachment parameter is a string with the attachment file
content
which will be named $filename.
Author: Rudolf Visagie (adapted from PHP Developers Cookbook by
Sterling Hughes)
*/
$boundary = "b".md5(uniqid(time()));
$mime = "From: $addr_from\r\n";
$mime .= "Reply-To: $addr_from\r\n";
$mime .= "X-Mailer: Digital Healthcare Solutions\r\n";
$mime .= "X-Sender: $addr_from\r\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))."\r\n";
$mime .= "--$boundary--";
mail ($to, $subject, "", $mime);
}
Rudolf Visagie
Principal Software Developer
Digital Healthcare Solutions
Tel. +27(0)11 266 6946
Fax. +27(0)11 266 5080
Cell: +27(0)82 895 1598
E-mail: [EMAIL PROTECTED]
-Original Message-
From: Jeremy Reed [mailto:[EMAIL PROTECTED]]
Sent: 13 December 2001 05:22
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Sending letter with attaching of the file
You cannot attach a file using the mail() function in PHP. You will have to
use a SMTP PHP class or another MIME enabled class to use attachments.
Jeremy
"Alexandr Klaus" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Help me !
>
> For sending a letter I using the mail function in PHP.
> How send the letter with attached file?
>
> --
> Alexandr Klaus
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]