Hello Guys,

My problem is when i am attaching files and sending in mail through PHP code everything is working fine and i am getting attached files to email. But if the destination address is of yahoo or hotmail then they the attached file is not displaying. It is displaying in encoding format !
What should i do ? Where as for gmail and others it is working fine !

Any mistake in conveying xcuse me as this is my first post !

Hope i ll get an answer here !

Recommended Answers

All 3 Replies

Are you using PHP Mailer ?

No. This is the code im using

   $body=       "----------------------------Messagee--------------------------------\n" .
   "Upload: " . $_FILES["fileatt"]["name"] . "<br />";
 "Type: " . $_FILES["fileatt"]["type"] . "<br />";
 "Size: " . ($_FILES["fileatt"]["size"] / 1024) . " Kb<br />";
 "Temp file: " . $_FILES["fileatt"]["tmp_name"] . "<br />";

                    "uplode_file/" . $fileUp);
                     "Stored in: " . "uplode_file/" . $fileUp;
$fileatt = $dest; // Path to the file
$fileatt_type = $_FILES["fileatt"]["type"]; // File Type
$fileatt_name = $_FILES["fileatt"]["name"]; // Filename that will be used for the file as the attachment
   foreach ($id as $value)
			 "$value is checked";
			 $sat="select * from  registration where reg_id='$value' ";
			$headers = "From: $from";
			 $fileatt= $dest;
		 $file = fopen($fileatt,'rb');
		 $data = fread($file,filesize($fileatt));
		   // 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\r\n" .
					 "Content-Type: multipart/mixed;\n" .
					 " boundary=\"{$mime_boundary}\"\r\n\r\n";
					 // Add a multipart boundary above the plain message
		 $message = "This is a multi-part message in MIME format.\r\n\r\n" .
					"--{$mime_boundary}\r\n" .
					"Content-Type: text/plain; charset=\"iso-8859-1\"\r\n" .
					"Content-Transfer-Encoding: 7bit\r\n\r\n" .
					$body . "\r\n\r\n";
					// Base64 encode the file data
		 $data1= chunk_split(base64_encode($data),72);
		 // print("<pre>$data1</pre>");
		 // Add file attachment to the message
		 $message .= "--{$mime_boundary}\r\r" .
					 "Content-Type: {$fileatt_type};\r\n" .
					 " name=\"{$orgname}\"\r\n" .
					  "Content-Disposition: attachment; filename=\"{$orgname}\"\r\n" .
					   "Content-Transfer-Encoding: base64\r\n\r\n" .
					  $data1 . "\r\n\r\n" .
			$ok = @mail($toemail, $sub, $message, $headers);
			if ($ok)
echo "Sucess";
echo "Failed Try Again";

There must something that breaks the email.
I would recommend you to rewrite that script and use PHP Mailer



// Instantiate your new class
$mail = new MyMailer;

// Now you only need to add the necessary stuff
$mail->AddAddress("josh@site.com", "Josh Adams");
$mail->Subject = "Here is the subject";
$mail->Body    = "This is the message body";
$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name

   echo "There was an error sending the message";

echo "Message was sent successfully";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.