Made some progress today. Found an attachment script in the archives. I was able to send an email attachment if it was already on the server. now i just need the file to come from a form instead of already being on the server but that's not working yet.
----HTML form code to submit file user wants uploaded------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Form Test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data" name="form1"> File to upload: <input type="file" name="fileatt"> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> ----------end html code---------- -----------upload.php code------------- <?php $to = "[EMAIL PROTECTED]"; $from = "[EMAIL PROTECTED]"; $subject = "Attachment Test"; $message = "Dear mike,<br> Thank you for taking the time to subscribe for our free document.<br> Please find the document attached to this email."; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; // If the file exists... if (!file_exists($fileatt)) { echo "the file doesn't exist"; } if (file_exists($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } mail($to, $subject, $message, $headers); echo "Thanks for sending mail"; ?> -----------end upload.php code----- any suggestions on how to get this form going???? thanks a million, you've been a big help, Mike ----- Original Message ----- From: "Jason Wong" <[EMAIL PROTECTED]> Newsgroups: php.general To: <[EMAIL PROTECTED]> Sent: Thursday, April 03, 2003 11:48 AM Subject: Re: [PHP] PHP Email Attachment problem > On Thursday 03 April 2003 22:30, Michael Arena wrote: > > > I just checked the directory that I specified for temporary uploads > > (/tmpuploads) and there is nothing there which leads me to believe the file > > isn't getting uploaded. > > I'm not sure *how* you're checking that there's nothing there but please read > the chapter in the manual about file uploads (yes all of it) and note that > uploaded files are deleted upon termination of the script. > > > Does the PHP code look ok? I suspect there's > > something in there that's not right. > > OK, you said on the RAQ server you don't get an attachment, have you checked > that: > > if (is_uploaded_file($fileatt)) > > is true? > > > I could email you a copy of my PHP.ini file > > No thank you. > > > if you want to check that out > > as well because I didn't see anything in there called file_upload. > > Make sure your php.ini has the following line > > file_uploads = On > > Also make sure you're not uploading any files that are exceeding the limits > set in php.ini (see manual for the relevant config settings which governs > this). > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > ------------------------------------------ > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > ------------------------------------------ > /* > spagmumps, n.: > Any of the millions of Styrofoam wads that accompany mail-order items. > -- "Sniglets", Rich Hall & Friends > */ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php