JranZu Posted June 22, 2007 Share Posted June 22, 2007 Hi I have the following script on my site. When a user submits an application the attachment doesn't come through in a readable format. I am pretty sure this is an error with the header but can not nail it down. It did work at one time, then I changed something (wish I could remember what) -- If someone could take a look at the code as see if they find a problem that would be great. Thanks, Tony <? switch ($_POST[education]){ case 0: $education = 'None'; break; case 1: $education = 'Still in High School'; break; case 2: $education = 'High School or GED'; break; case 3: $education = 'Trade School'; break; case 4: $education = 'Some College'; break; case 5: $education = 'College Grad'; break; default: $education = 'error'; break; } $from_name = "capitalbizserv.com resume submitter"; $subject = $_POST[name] . " has submitted a resume."; //$body = stripslashes($_POST['body']); $attachment = $_FILES['resumeupload']['tmp_name']; $attachment_name = $_FILES['resumeupload']['name']; if (is_uploaded_file($attachment)) { //Do we have a file uploaded? $fp = fopen($attachment, "rb"); //Open it $data = fread($fp, filesize($attachment)); //Read it $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed fclose($fp); } //Let's start our headers $headers = "From: $from_name<" . $_POST['from_email'] . ">\n"; $headers .= "Reply-To: <" . $_POST['from_email'] . ">\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n\n"; $headers .= "X-Sender: $from_name<" . $_POST['from_email'] . ">\n"; $headers .= "X-Mailer: PHP4\n"; $headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal $headers .= "Return-Path: <" . $_POST['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\n"; $message = "------=MIME_BOUNDRY_message_parts\n"; $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n"; $message .= "Content-Transfer-Encoding: quoted-printable\n"; $message .= "\n\n"; $body .= 'Name: '. $_POST[name] . ', E-mail: ' . $_POST . "\n\n" . ', Home Phone: ' . $_POST[homePhone] . ', Mobile Phone: ' . $_POST[mobilePhone] . "\n\n" . 'Address: ' . $_POST[address] . ' ' . $_POST[city] . ', ' . $_POST[state] . ' ' . $_POST[zip] . "\n\n" . 'They can start on: ' . $_POST[startDate] . ', and would like to make: ' . $_POST[desiredWage] . "\n\n" . 'They are available on Monday: ' . $_POST[monAva] . ',' . ' Tuesday: ' . $_POST[tuesAva] . ',' . ' Wednesday: ' . $_POST[wedAva] . ',' . ' Thursday: ' . $_POST[thurAva] . ',' . ' Friday: ' . $_POST[friAva] . "\n\n" . 'They heard about us from: ' . $_POST[hearaboutus] . "\n\n\n" . 'Their last/current job info is: ' . $_POST[companyName1] . ' ' . $_POST[startDate1] . ' - ' . $_POST[endDate1] . ' ' . $_POST[contactNumber1] . "\n\n" . 'They started at '. $_POST[startWage1] . ' and ended at ' . $_POST[endWage1] . "\n\n" . 'They left because ' . $_POST[Left1] . "\n\n" . 'Their job duties included: ' . $_POST[duties1] . "\n\n" . '2nd job info is: ' . $_POST[companyName2] . ' ' . $_POST[startDate2] . ' - ' . $_POST[endDate2] . ' ' . $_POST[contactNumber2] . "\n\n" . 'They started at '. $_POST[startWage2] . ' and ended at ' . $_POST[endWage2] . "\n\n" . 'They left because ' . $_POST[Left2] . "\n\n" . 'Their job duties included: ' . $_POST[duties2] . "\n\n" . '3rd job info is: ' . $_POST[companyName3] . ' ' . $_POST[startDate3] . ' - ' . $_POST[endDate3] . ' ' . $_POST[contactNumber3] . "\n\n" . 'They started at '. $_POST[startWage3] . ' and ended at ' . $_POST[endWage3] . "\n\n" . 'They left because ' . $_POST[Left3] . "\n\n" . 'Their job duties included: ' . $_POST[duties3] . "\n\n\n" . 'The highest level of education compleated is: ' . "$education" . "\n\n" . 'They have the following skills: ' . $_POST[skills] . "\n\n" . 'They would like to use the following references: ' . $_POST[References] . "\n\n" . 'We should hire them because: ' . $_POST[whyhire] . "\n\n" . 'And they will be motivated by: ' . $_POST[motivation] . "\n\n"; $message .= "$body\n"; $message .= "\n\n"; $message .= "------=MIME_BOUNDRY_message_parts--\n"; $message .= "\n\n"; $message .= "------=MIME_BOUNDRY_main_message\n"; $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n"; $message .= $data; //The base64 encoded message $message .= "\n\n"; $message .= "------=MIME_BOUNDRY_main_message--\n"; // send the message mail("[email protected]", $subject, $message, $headers); header("Location: thankyou.php"); ?> Link to comment https://forums.phpfreaks.com/topic/56792-help-with-mail-script/ Share on other sites More sharing options...
teng84 Posted June 22, 2007 Share Posted June 22, 2007 http://www.php.net/mail Link to comment https://forums.phpfreaks.com/topic/56792-help-with-mail-script/#findComment-280551 Share on other sites More sharing options...
JranZu Posted June 23, 2007 Author Share Posted June 23, 2007 I understand the basics of the mail function. Something is broken and I just can't find what it is. But thanks for the link. Link to comment https://forums.phpfreaks.com/topic/56792-help-with-mail-script/#findComment-280622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.