toose Posted October 10, 2010 Share Posted October 10, 2010 Hey folks, first time here - I was wondering if you guys could help me out with a problem I'm having. Here's my code: $qName = cleanString($_POST['q_name']);$qCompany = cleanString($_POST['q_company']);$qEmail = cleanString($_POST['q_email']);$qPhone = cleanString($_POST['q_phone']);$qAddress = cleanString($_POST['q_address']);$qSize = cleanString($_POST['q_size']);$qQuantity = $_POST['q_quantity'];$qPurpose = cleanString($_POST['q_purpose']);$qInfo = cleanString($_POST['q_info']);$qIp = $_SERVER['REMOTE_ADDR'];if($_FILES["q_file"]["error"] == 0) { if( ( ($_FILES["q_file"]["type"] == "image/gif") || ($_FILES["q_file"]["type"] == "application/pdf") || ($_FILES["q_file"]["type"] == "image/png") || ($_FILES["q_file"]["type"] == "application/x-photoshop") || ($_FILES["q_file"]["type"] == "image/jpeg") || ($_FILES["q_file"]["type"] == "image/pjpeg") ) && ($_FILES["q_file"]["size"] < 2000000)) { if($_FILES["q_file"]["error"] > 0) { echo "<p>Error</p>"; } else { $fileName = $_FILES["q_file"]["name"]; $fileType = $_FILES["q_file"]["type"]; $fileSize = ($_FILES["q_file"]["size"] / 1024)." Kb"; $attachment = $_FILES['q_file']['tmp_name']; $attachment_name = $_FILES['q_file']['name']; if(is_uploaded_file($attachment)) { $fp = fopen($attachment, "rb"); $data = fread($fp, filesize($attachment)); $data = chunk_split(base64_encode($data)); fclose($fp); } } } else { echo "<p>Error</p>"; }} else { $data = ""; $attachment_name = "";}$to = "[email protected]"; $subject = "Formail"; $boundary = $siteName.md5(date('r',time()));$headers = "From: Formail <$contactFromEmail>\n"; $headers .= "Reply-To: $qName <$qEmail>\n";$headers .= "MIME-Version: 1.0\n";$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";$message = "--$boundary\n";$message .= "Content-Type: multipart/alternative; boundary=\"$boundary\"\n";$message .= "--$boundary\n";$message .= "Content-Type: text/html; charset=UTF-8\n";$message .= "Content-Transfer-Encoding: 8bit\n\n";$message .= "<html>\n";$message .= "<body style=\"font-family:Verdana, sans-serif; font-size:12px; color:#333333;\">\n";$message .= "<h3>You have received the following quick quote request.</h3>\n\n";$message .= "Name:<br><b>$qName</b><br><br>\n\n";$message .= "Company Name:<br><b>$qCompany</b><br><br>\n\n";$message .= "Contact Email:<br><b>$qEmail</b><br><br>\n\n";$message .= "Contact Number:<br><b>$qPhone</b><br><br>\n\n";$message .= "Delivery Address:<br><b>$qAddress</b><br><br>\n\n";$message .= "Product Size:<br><b>$qSize</b><br><br>\n\n";$message .= "Product Quantity:<br><b>$qQuantity</b><br><br>\n\n";$message .= "Product Purpose:<br><b>$qPurpose</b><br><br>\n\n";$message .= "Additional Information:<br><b>$qInfo</b><br><br>\n\n";$message .= "User IP:<br><b>$qIp</b><br><br>\n\n";$message .= "Attachment:<br>\n\n";$message .= "Name: <b>$fileName</b><br>\n\n";$message .= "Type: <b>$fileType</b><br>\n\n";$message .= "Size: <b>$fileSize</b><br><br>\n\n";$message .= "</body>\n";$message .= "</html>\n";$message .= "--$boundary--\n";$message .= "--$boundary\n";$message .= "Content-Type: application/octet-stream; name=$attachment_name\n";$message .= "Content-Transfer-Encoding: base64\n";$message .= "Content-Disposition: attachment\n";$message .= $data;$message .= "\n\n";$message .= "--$boundary--\n";$mail_sent = @mail($to,$subject,$message,$headers);if($mail_sent) { echo "<p>Email sent!</p>";} else { echo "<p>Email not sent.</p>";} I did have a plain text version of the message in there but Outlook was showing both (although GMail and Apple Mail were working fine) so I took it out for now whilst I get to grips with email structures a bit better. The main problem is that attachments aren't being sent, I was wondering if anybody had any ideas where I've been going wrong. Thanks Link to comment https://forums.phpfreaks.com/topic/215568-formail-attachment-problems/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.