Jump to content

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


mjlogan

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?

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.