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 !

No. This is the code im using

$id=$_SESSION['mailid'];
  $sub=$_POST[subj];
  $msg=$_POST[message];
   $body=       "----------------------------Messagee--------------------------------\n" .
			  "$msg\n";
  $from="info@mydomain.com";
   "Upload: " . $_FILES["fileatt"]["name"] . "<br />";
 "Type: " . $_FILES["fileatt"]["type"] . "<br />";
 "Size: " . ($_FILES["fileatt"]["size"] / 1024) . " Kb<br />";
 "Temp file: " . $_FILES["fileatt"]["tmp_name"] . "<br />";

if(is_uploaded_file($_FILES["fileatt"]["tmp_name"]))
						{
						$tmpname=$_FILES["fileatt"]["tmp_name"];
						$orgname=$_FILES["fileatt"]["name"];
						$fileUp=time()."_".$orgname;
						$dest="uplode_file/".$fileUp;
					 move_uploaded_file($_FILES["fileatt"]["tmp_name"],
                    "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' ";
			$res_del=mysql_query($sat);
			$row=mysql_fetch_object($res_del);
			$toemail=$row->email;	
			$headers = "From: $from";
			 $fileatt= $dest;
		 $file = fopen($fileatt,'rb');
		 $data = fread($file,filesize($fileatt));
		 fclose($file);
		   // 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" .
					 "--{$mime_boundary}--\r\n\r\n\r\n";
					 
			$ok = @mail($toemail, $sub, $message, $headers);
			if ($ok)
				 {
echo "Sucess";
				 } 
			else
				 {
echo "Failed Try Again";
				 }

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

http://sourceforge.net/project/showfiles.php?group_id=26031

require("mail.inc.php");

// 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

if(!$mail->Send())
{
   echo "There was an error sending the message";
   exit;
}

echo "Message was sent successfully";
This article has been dead for over six months. Start a new discussion instead.