Hi there I am trying to get the scriplet code from http://www.phpwizard.net/resources/phpMisc/scripts/pretty/mail.php3 to work for a website I'm building. I am trying to allow a user to select a file from their hard drive, and then have that file sent as an email attachment. Most of the time that file will be a Microsoft Word document. I have the code for the file selection all done, and I integrated the codelet (THANK YOU) into my code, and when I attach a .jpg file, it works fine, but if I choose a word doc, it attaches what it thinks is an image. I changed the line $mail->add_attachment("$attachment", $copy_filename, "application/msword"); to reflect the mime type for application/msword, but it still doesn't work. What suggestions might you have? url to see it in action http://www.emergejobs.com/jen/jen_file_upload.phtml the submit script that does the file upload then the email send is below. thank you SO MUCH -jen . ----- jen_file_upload_submit.phtml: <html><head><title>Jen's file upload module</title></head> <BODY bgcolor="#666699" link="#FF9933" text="#FFFFFF" vlink="#FF8040"> <font face="arial, helvetica, sans-serif"> <P><h1>file upload</h1><P> <?php $directory_to_copy_to = "/home/web/e/emerge/virtual_html/jen/"; function is_uploaded_file($filename) { if (!$tmp_file = get_cfg_var('upload_tmp_dir')) { $tmp_file = dirname(tempnam('', '')); } $tmp_file .= '/' . basename($filename); /* User might have trailing slash in php.ini... */ return (ereg_replace('/+', '/', $tmp_file) == $filename); } if (is_uploaded_file($userfile)) { $clean_filename = ereg_replace(" ","_",$userfile_name); $clean_filename = strtoupper($clean_filename); $copy_filename = $directory_to_copy_to . $clean_filename; copy($userfile, $copy_filename); unlink($userfile); echo "<P>you uploaded $userfile, <P>this script just renamed it (and made it all caps) to $clean_filename <P>and copied it to $copy_filename"; } else { echo "ERROR there was an error uploading the file: '$userfile' ($userfile_name)."; } /* * Class mime_mail * Original implementation by Sascha Schumann <[EMAIL PROTECTED]> * Modified by Tobias Ratschiller <[EMAIL PROTECTED]>: * - General code clean-up * - separate body- and from-property * - killed some mostly un-necessary stuff */ class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body; /* * void mime_mail() * class constructor */ function mime_mail() { $this->parts = array(); $this->to = ""; $this->from = ""; $this->subject = ""; $this->body = ""; $this->headers = ""; } /* * void add_attachment(string message, [string name], [string ctype]) * Add an attachment to the mail object */ function add_attachment($message, $name = "", $ctype = "application/octet-stream") { $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name ); } /* * void build_message(array part= * Build message parts of an multipart mail */ function build_message($part) { $message = $part[ "message"]; $message = chunk_split(base64_encode($message)); $encoding = "base64"; return "Content-Type: ".$part[ "ctype"]. ($part[ "name"]? "; name = \"".$part[ "name"]. "\"" : ""). "\nContent-Transfer-Encoding: $encoding\n\n$message\n"; } /* * void build_multipart() * Build a multipart mail */ function build_multipart() { $boundary = "b".md5(uniqid(time())); $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary"; for($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n".$this->build_message($this->parts[$i]). "--$boundary"; } return $multipart.= "--\n"; } /* * void send() * Send the mail (last class-function to be called) */ function send() { $mime = ""; if (!empty($this->from)) $mime .= "From: ".$this->from. "\n"; if (!empty($this->headers)) $mime .= $this->headers. "\n"; if (!empty($this->body)) $this->add_attachment($this->body, "", "text/plain"); $mime .= "MIME-Version: 1.0\n".$this->build_multipart(); mail($this->to, $this->subject, "", $mime); } }; // end of class /* * Example usage */ $attachment = fread(fopen($copy_filename, "r"), filesize($copy_filename)); $mail = new mime_mail(); $mail->from = "[EMAIL PROTECTED]"; $mail->headers = "Errors-To: [EMAIL PROTECTED]"; $mail->to = "[EMAIL PROTECTED]"; $mail->subject = "Testing email attachment..."; $mail->body = "This is just a test."; $mail->add_attachment("$attachment", $copy_filename, "application/msword"); $mail->send(); ?> <P>end of script. </body></html> -- 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]