mjlogan Posted September 28, 2006 Share Posted September 28, 2006 Whenever I send an email through the function below, I always end up with the attachment and a blank text file name something usually like ATT32638491.txt. These are always blank. I am current using Outlook, but the emails will be sent to many people using many different programs.Anybody notice anything obvious?[code=php:0]function xmail($email_address,$email_from,$from_name,$subject,$msg,$attach_filepath) { $b = 0; $mail_attached = ""; $boundary = md5(uniqid(time(),1))."_xmail"; if (count($attach_filepath)>0) { if ($fp = fopen($attach_filepath,"rb")) { $file_name = basename($attach_filepath); $content = fread($fp,filesize($attach_filepath)); $mail_attached .= "--".$boundary."\r\n" ."Content-Type: image/jpeg; name=\"$file_name\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-Disposition: attachment; filename=\"$file_name\"\r\n\r\n" .chunk_split(base64_encode($content))."\r\n"; fclose($fp); } $mail_attached .= "--".$boundary." \r\n"; $add_header ="MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"$boundary\""; $mail_content = "--".$boundary."\r\n" . "Content-Type: text/plain; charset=iso-8859-1; format=flowed\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n" . $msg."\r\n\r\n".$mail_attached; return mail($email_address,$subject,$mail_content,"From: $from_name <$email_from>\r\n$add_header","$email_from"); } else { return mail($email_address,$subject,$msg,"From: ".$from_name."<".$email_from.">"); } } [/code] Link to comment https://forums.phpfreaks.com/topic/22358-email-attachments-aattxt/ Share on other sites More sharing options...
steveclondon Posted September 28, 2006 Share Posted September 28, 2006 For what you are doing why not download a php email class like the one below. Very easy to use and will put your attachements in no problem.http://phpmailer.sourceforge.net/ Link to comment https://forums.phpfreaks.com/topic/22358-email-attachments-aattxt/#findComment-100133 Share on other sites More sharing options...
mjlogan Posted September 28, 2006 Author Share Posted September 28, 2006 Because I have the function there setup perfectly to work on mulitple pages in multiple files, it works perfectly apart from one this, the random AAT######.txt text file that is added (something to do with incorrect formatting).I don't really want to have to change over many files to intergrate a new class. Link to comment https://forums.phpfreaks.com/topic/22358-email-attachments-aattxt/#findComment-100191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.