Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 mjlogan

mjlogan
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 28 September 2006 - 09:08 AM

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




#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 28 September 2006 - 09:45 AM

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/

#3 mjlogan

mjlogan
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 28 September 2006 - 12:27 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users