![]() |
Email attachment
I can get 1 attachment to go through but not the secound one.
Here is the code: Note the first the picture shows but note the second. <? $Name=$_POST["Name"]; $Address=$_POST["Address"]; $City=$_POST["City"]; $State=$_POST["State"]; $Zip=$_POST["Zip"]; $Phone=$_POST["Phone"]; $Cell=$_POST["Cell"]; $Fax=$_POST["Fax"]; $Email=$_POST["Email"]; $DogsName=$_POST["DogsName"]; $DogsAge=$_POST["DogsAge"]; $Breed=$_POST["Breed"]; $DogsWeight=$_POST["DogsWeight"]; $DogsSex=$_POST["DogsSex"]; $SpayedNeutered=$_POST["SpayedNeutered"]; $Medications=$_POST["Medications"]; $Diet=$_POST["Diet"]; $Exercise=$_POST["Exercise"]; $Story=$_POST["Story"]; $Diabetes=$_POST["Diabetes"]; $KidneyLiver=$_POST["KidneyLiver"]; $FoodAllergies=$_POST["FoodAllergies"]; $HeartDisease=$_POST["HeartDisease"]; $Other=$_POST["Other"]; $entrant = sprintf("Please Enter Us Into the Healthiest Hound Contest: %s\n\nName: %s\n\nAddress: %s %s\n\nPhone:%s\n\nCell Phone: %s\n\nEmail: %s\n", $Name, $Address, $City, $State, $Zip, $Phone, $Cell, $Email); $hound = sprintf("Description of Hound to Be Entered:\nName: %s, Age: %s, Breed: %s, Weight: %s, Sex: %s, Spayed/Neutered: %s\n\n\n", $DogsName, $DogsAge, $Breed, $DogsWeight, $DogsSex, $SpayedNeutered); $details = sprintf("Medications:\n\n%s\n\nDiet:\n\n%s\n\nExer cise: %s\n\nStory: %s\n\n\n", $Medications, $Diet, $Exercise, $Story); $ailments = sprintf("Diabetes: %s\n\nKidney/Liver Disease: %s\n\nFood Allergies: %s\n\nHeart Disease: %s\n\nOther: %s\n\n", $Diabetes, $KidneyLiver, $FoodAllergies, $HeartDisease, $Other); $body1 = sprintf("%s\n%s\n%s\n%s\n", $entrant, $hound, $details, $ailments); $body2 = sprintf("Thank You For Applying to Our Curb Your Pouch Contest\nWe will get back with you in several working days\nHere is the info you sent us. Thanks Again!!\n\n%s", $body1); $to = "$Name <$Email>"; $from = "Info Curb Your Pouch $subject = "Application Curb Your Pouch"; if ($_FILES["Picture1"]["error"] > 0) { echo "Return Code: " . $_FILES["Picture1"]["error"] . "<br />"; } else if (is_uploaded_file($_FILES['Picture1']['tmp_name'])) { echo "Upload: " . $_FILES["Picture1"]["name"] . "<br />"; echo "Type: " . $_FILES["Picture1"]["type"] . "<br />"; echo "Size: " . ($_FILES["Picture1"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["Picture1"]["tmp_name"] . "<br />"; } else { echo "File Not Uploaded: "; echo "filename '". $_FILES['Picture1']['tmp_name'] . "'."; } if ($_FILES["Picture2"]["error"] > 0) { echo "Return Code: " . $_FILES["Picture2"]["error"] . "<br />"; } else if (is_uploaded_file($_FILES['Picture2']['tmp_name'])) { echo "Upload: " . $_FILES["Picture2"]["name"] . "<br />"; echo "Type: " . $_FILES["Picture2"]["type"] . "<br />"; echo "Size: " . ($_FILES["Picture2"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["Picture2"]["tmp_name"] . "<br />"; } else { echo "File Not Uploaded: "; echo "filename '". $_FILES['Picture2']['tmp_name'] . "'."; } $headers = "From: $from\r\n"; $headers .= "Bcc: my@email.com"; $semi_rand = md5( time() ); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $body2 . "\n\n"; $fileatt = $_FILES["Picture1"]["tmp_name"]; $fileattname = "sideview.jpg"; $fileatttype = $_FILES["Picture1"]["type"]; $file = fopen( $fileatt, 'rb' ); $data = fread( $file, $_FILES["Picture1"]["size"]); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatttype};\n" . " name=\"{$fileattname}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileattname}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; unset($data); unset($file); unset($fileatt); unset($fileatttype); unset($fileattname); $fileatt2 = $_FILES["Picture2"]["tmp_name"]; $fileatt2name = "topview.jpg"; $fileatt2type = $_FILES["Picture2"]["type"]; $file2 = fopen( $fileatt2, 'rb' ); $data2 = fread( $file2, $_FILES["Picture2"]["size"]); fclose($file2); $data2 = chunk_split(base64_encode($data2)); $message .= "Content-Type: {$fileatttype};\n" . " name=\"{$fileattname}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileattname}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data2 . "\n\n" . "--{$mime_boundary}--\n"; unset($data2); unset($file2); unset($fileatt2); unset($fileatt2type); unset($fileatt2name); if( mail( $to, $subject, $message, $headers ) ) echo "<p>The email was sent.</p>"; else echo "<p>There was an error sending the mail.</p>"; ?> |
| All times are GMT. The time now is 09:18 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0