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.
- <?php
- function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject) {
- $file = $path.$filename;
- $file_size = filesize($file);
- $handle = fopen($file, "r");
- $content = fread($handle, $file_size);
- fclose($handle);
- $content = chunk_split(base64_encode($content));
- $uid = md5(uniqid(time()));
- $name = basename($file);
- $eol = PHP_EOL;
- // Basic headers
- $header = "From: ".$from_name." <".$from_mail.">".$eol;
- $header .= "Reply-To: ".$replyto.$eol;
- $header .= "MIME-Version: 1.0\r\n";
- $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"";
- // Put everything else in $message
- $message = "--".$uid.$eol;
- $message .= "Content-Type: text/html; charset=ISO-8859-1".$eol;
- $message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
- $message .= "<html><body><h1>Contact Us</h1>".
- "<p>A message was submitted from the Contact form. The following information was provided.</p>".
- "<table rules='all' style='border-color: #666;' cellpadding='10'>".
- "<tr><td> Name </td><td>".$_POST['apply-name']."</td></tr>".
- "<tr><td> Email </td><td>".$_POST['apply-email']."</td></tr>".
- "<tr><td> Message </td><td>".$_POST['apply-desc']."</td></tr>"."</table></body></html>".$eol;
- $message .= "--".$uid.$eol;
- $message .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
- $message .= "Content-Transfer-Encoding: base64".$eol;
- $message .= "Content-Disposition: attachment;".$eol;
- $message .= $content.$eol.$eol;
- $message .= "--".$uid."--";
- if (mail($mailto, $subject, $message, $header))
- {
- return "mail_success";
- }
- else
- {
- return "mail_error";
- }
- }
- if(isset($_POST['apply-name']) && isset($_POST['apply-email']) && isset($_POST['apply-desc']) && isset($_POST['uploaded-file'])) {
- $my_file = $_POST['uploaded-file'];
- $my_path = "../resume/";
- $my_name = "Madarth - Wesbite Contact";
- $my_mail = "interact@madarth.com";
- $my_replyto = "interact@madarth.com";
- $my_subject = "Application Form";
- mail_attachment($my_file, $my_path, "aravindanarayanan.m@gmail.com,aravind@madarth.com", $my_mail, $my_name, $my_replyto, $my_subject);
- }
- ?>