Search the Community
Showing results for tags 'imap'.
-
My code works, unless I send it to gmail, then the attachment doesn't show up, and the body shows: This is a multi-part message in MIME format. I'm assuming my headers are incorrect. $from = stripslashes($from_name)."<".stripslashes($from_email).">"; $uniqid = md5(uniqid(time())); $boundary = "--==_mimepart_".$uniqid; $headers = "From: ".$from."\n". 'Subject: '.$subject."\n". 'Reply-to: '.$from_email."\n". 'Return-Path: '.$from_email."\n". 'Message-ID: <'.$uniqid.'@'.$domain.">\n". 'Date: '.date("r", strtotime("now"))."\n". 'Mime-Version: 1.0'."\n". 'Content-Type: text/html;'."\n". ' boundary=PHP-mixed-'.$boundary.";\n". ' charset=UTF-8'."\n". 'X-Mailer: PHP/' . phpversion(); $headers .= 'Content-Type: multipart/mixed; boundary="'.$uniqid.'"\r\n\r\n'; $headers .= 'This is a multi-part message in MIME format.\r\n'; $headers .= '--'.$uniqid.'\r\n'; $headers .= 'Content-type:text/html; charset=iso-8859-1\r\n'; $headers .= 'Content-Transfer-Encoding: 7bit\r\n\r\n'; $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $message = $html; $count_uploaded_files = count( $uploaded_files['attachments']['tmp_name'] ); if($uploaded_files['attachments']['name'][0] != ""){ $headers .= "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; $message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; for( $i = 0; $i < $count_uploaded_files; $i++ ) { $tmp_name = $uploaded_files['attachments']['tmp_name'][$i]; $type = $uploaded_files['attachments']['type'][$i]; $name = $uploaded_files['attachments']['name'][$i]; $size = $uploaded_files['attachments']['size'][$i]; if (file_exists($tmp_name)){ if(is_uploaded_file($tmp_name)){ $file = fopen($tmp_name,'rb'); $data = fread($file,filesize($tmp_name)); fclose($file); $data = chunk_split(base64_encode($data)); } $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; } } $headers .= "--".$uniqid."--"; $message.="--{$mime_boundary}--\n"; }//end files sent mail($to_addresses, $subject, $message, $headers);
