Jump to content


This topic is now archived and is closed to further replies.


Email attachments + AAT######.txt

Recommended Posts

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?


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"
$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.">");


Share this post

Link to post
Share on other sites
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.


Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.