php mail with attachment works with gmail but not in zoho mail

php mail with attachment works with gmail but not in zoho mail

Hi,
I have a contact form with pdf/doc attachment.
And using php mail script to send it to gmail and zoho mail.
but in zoho mail there is no attachment bt gmail show the attachment.
  1. <?php 
  2. function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject) {
  3. $file = $path.$filename;
  4. $file_size = filesize($file);
  5. $handle = fopen($file, "r");
  6. $content = fread($handle, $file_size);
  7. fclose($handle);

  8. $content = chunk_split(base64_encode($content));
  9. $uid = md5(uniqid(time()));
  10. $name = basename($file);

  11. $eol = PHP_EOL;

  12. // Basic headers
  13. $header = "From: ".$from_name." <".$from_mail.">".$eol;
  14. $header .= "Reply-To: ".$replyto.$eol;
  15. $header .= "MIME-Version: 1.0\r\n";
  16. $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"";

  17. // Put everything else in $message
  18. $message = "--".$uid.$eol;
  19. $message .= "Content-Type: text/html; charset=ISO-8859-1".$eol;
  20. $message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  21. $message .= "<html><body><h1>Contact Us</h1>".
  22. "<p>A message was submitted from the Contact form. The following information was provided.</p>".
  23. "<table rules='all' style='border-color: #666;' cellpadding='10'>".
  24. "<tr><td> Name  </td><td>".$_POST['apply-name']."</td></tr>".
  25. "<tr><td> Email  </td><td>".$_POST['apply-email']."</td></tr>".
  26. "<tr><td> Message  </td><td>".$_POST['apply-desc']."</td></tr>"."</table></body></html>".$eol;
  27. $message .= "--".$uid.$eol;
  28. $message .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
  29. $message .= "Content-Transfer-Encoding: base64".$eol;
  30. $message .= "Content-Disposition: attachment;".$eol;
  31. $message .= $content.$eol.$eol;
  32. $message .= "--".$uid."--";

  33. if (mail($mailto, $subject, $message, $header))
  34. {
  35. return "mail_success";
  36. }
  37. else
  38. {
  39. return "mail_error";
  40. }
  41. }
  42. if(isset($_POST['apply-name']) && isset($_POST['apply-email']) && isset($_POST['apply-desc']) && isset($_POST['uploaded-file'])) {
  43. $my_file = $_POST['uploaded-file'];
  44. $my_path = "../resume/";
  45. $my_name = "Madarth - Wesbite Contact";
  46. $my_mail = "interact@madarth.com";
  47. $my_replyto = "interact@madarth.com";
  48. $my_subject = "Application Form";
  49. mail_attachment($my_file, $my_path, "aravindanarayanan.m@gmail.com,aravind@madarth.com", $my_mail, $my_name, $my_replyto, $my_subject);
  50. }

  51. ?>