Email attachment not working in gmail

Hi guys

I am sending attachments which work fine when opened in outlook but it does not work in Gmail

Here is my code


 <?php 
//define the receiver of the email 
$to = "$email"; 
//define the subject of the email 
$subject = "$messagesubject"; 
//create a boundary string. It must be unique 
//so we use the MD5 algorithm to generate a random hash 
$random_hash = md5(date('r', time())); 
//define the headers we want passed. Note that they are separated with \\r\
 
$headers = "From:info@joi-yoyaku.com\\r\
Reply-To:info@joi-yoyaku.com"; 
//add boundary string and mime type specification 
$headers .= "\\r\
Content-Type: multipart/mixed; boundary=\\"PHP-mixed-".$random_hash."\\""; 
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents("$target_path"))); 
//define the body of the message. 
ob_start(); //Turn on output buffering 
?> 
--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" 

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/plain; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit

<?echo"$messagecontent

";?> 



This message is sent from a No Reply address; to reply to messages please send to support@japonin.com
If the Japanese in this email is warped, please change the email encoding settings to UTF-8

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/html; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit

<?echo"$messagecontent

";?>



This message is sent from a No Reply address; to reply to messages please send to support@japonin.com
If the Japanese in this email is warped, please change the email encoding settings to UTF-8
   <? if($target_path2!=''){ ?>
--PHP-alt-<?php echo $random_hash; ?>-- 

--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: application/zip; name="<?php echo $target_path2; ?>"  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment  

<?php echo $attachment; ?> 
--PHP-mixed-<?php echo $random_hash; ?>-- 
   
   <? } ?>
<?php 
//copy current buffer contents into $message variable and delete current output buffer 
$message = ob_get_clean(); 
//send the email 
$mail_sent = mail( $to, $subject, $message, $headers ); 

?>

2 questions: What is the file-type of the attachment and what is the error in GMail?

the file type is .DOC

It gives a load of numbers and letters and doesnt attach anything