Jump to content

Formail attachment problems


toose

Recommended Posts

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 = "me@mydomain.com"; $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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.