Is this a stupid question, or does no one know what is wrong??? Thanks! Shawn
"Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I got this from the user contributed notes in the php.net manual. It seems > to work fine most of the time, but Eudora and Pegasus users either get > mangled attachments or no attachments. > > Can anyone see a problem (most files are zip, but sometimes tar.gz or sit) I > tried using Content-Type: application/zip with the same results. I'm > thinking it is some issue with the headers, content-types, boundaries or > something. Or maybe Pegasus/Eudora don't understand MIME or base64 > (doubtful)??? > > Help appreciated. Thanks! > > function send_mail($from_name, $from_email, $to_name, $to_email, $subject, > $text, $path, $filename) > { > // encode file attachments > foreach($filename as $key => $file) { > $fp = fopen($path[$key].$file, "r"); > $content = fread($fp, filesize($path[$key].$file)); > $attachment[$key] = chunk_split(base64_encode($content)); > } > // headers need to be in the correct order... > $headers = "From: $from_name<$from_email>\n"; > $headers .= "Reply-To: <$from_email>\n"; > $headers .= "MIME-Version: 1.0\n"; > > // the following must be one line (post width too small) > $headers .= "Content-Type: multipart/related; > type=\"multipart/alternative\"; > boundary=\"----=MIME_BOUNDRY_main_message\"\n"; > $headers .= "X-Sender: $from_name<$from_email>\n"; > $headers .= "X-Mailer: PHP4\n"; //mailer > $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal > $headers .= "Return-Path: <$from_email>\n"; > $headers .= "This is a multi-part message in MIME format.\n"; > $headers .= "------=MIME_BOUNDRY_main_message \n"; > $headers .= "Content-Type: multipart/alternative; > boundary=\"----=MIME_BOUNDRY_message_parts\"\n"; > > // plaintext section begins > $message = "------=MIME_BOUNDRY_message_parts\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 .= "$text\n"; > $message .= "\n"; > > // this ends the message part > $message .= "------=MIME_BOUNDRY_message_parts--\n"; > $message .= "\n"; > > // now we add attachments (images, etc) > foreach($filename as $key => $file) { > $message .= "------=MIME_BOUNDRY_main_message\n"; > $message .= "Content-Type: application/octet-stream; > name=\"$file\"\n"; > $message .= "Content-disposition: attachment\n"; > $message .= "Content-Transfer-Encoding: base64\n"; > $message .= "\n"; > $message .= "$attachment[$key]\n"; > $message .= "\n"; > } > // message ends > $message .= "------=MIME_BOUNDRY_main_message--\n"; > > // send the message > $stat = mail("$to_name<$to_email>", $subject, $message, $headers); > return $stat; > } > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php