arun_php Posted June 27, 2008 Share Posted June 27, 2008 Hello friends, i want to send the mail by using mail function but mail is working and all the data is receiving ,if i attached the file means attaching after sending file name will beas "noname" with 0kb but i can download it please help me <?php if ($_SERVER['REQUEST_METHOD']=='POST') { $strname=ucfirst($_REQUEST["strname"]); $filename=$_FILES["strresume"]["name"]; $filetype=$_FILES["strresume"]["type"]; $filesize=$_FILES["strresume"]["size"]; $filetemp=$_FILES["strresume"]["tmp_name"]; if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword") { $message= ' <table cellspacing="0" cellpadding="8" border="0" width="400"> <tr> <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td> <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strname.'</td> </tr> </table>'; $subject = "Mail with doc file attachment"; $to="[email protected]"; //$fp = fopen($strresume, "rb"); // $file = fread($fp, $strresume_size); // $file = chunk_split(base64_encode($file)); $filename= fopen($filetemp,'rb'); $data=fread($filename,filesize($filetemp)); $data=chunk_split(base64_encode($data)); fclose($filename); $num = md5(time()); $headers = "From: Name<[email protected]>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; $dd = mail($to, $subject, $message, $headers); //fclose($fp); echo "sent"; }else { echo "failed"; } } Link to comment https://forums.phpfreaks.com/topic/112186-file-is-not-attaching-in-mail/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.