email attachment cannot be opened

From: Date: Fri, 12 Sep 2003 17:46:03 +0000
Subject: email attachment cannot be opened
Groups: php.general 
Request: Send a blank email to php-general+get-162448@lists.php.net to get a copy of this message
hi, I've made a form to send out emails with attachments, and the attachments look ok when they arrive but the content is somehow bad. I cannot open gifs nor can word open the documents. Looking at the content something may be wrong with the encoding: if i open the GIF file the normal one as well as the attachment I sent start with GIF89a, but then they start to be different. I think this is the relevant part of my code: $atta_type=$_FILES['AttachedFile']['type']; if (strpos($atta_type,';')){$atta_type=substr($atta_type,0,strpos($atta_type,';'));} //for Opera $atta_tmp_name=$_FILES['AttachedFile']['tmp_name']; $fp = fopen($atta_tmp_name,"rb");
	 	while (!feof($fp)){    $filedata .= addslashes(fread($fp,1200));}
$filedata = chunk_split(base64_encode($filedata)); $attachment = $atta_type."\n\n" ."--$boundary\n" ."Content-Type: $atta_type"."; name = \"$atta_name\"\n" ."Content-Transfer-Encoding: $encoding"
	       		."\n\n$filedata\n\n"
."--$boundary--\n"; Just for fun the headers as well: 'From: "SENSE mailinglist" <mailinglist@sense.nl>' 'Subject: '.$subject 'Reply-To: mailinglist_reply@sense.nl' 'Return-Receipt-To: mailinglist_return_receipt@sense.nl' 'Return-Path: mailinglist_returned@sense.nl' 'MIME-Version: 1.0' 'Content-Type: multipart/mixed; boundary="'.$boundary."\"\n\n");////'To: SENSE_List' "This is a MIME encoded message. \n\n"
    			."--$boundary\n"
    			."Content-Type: ".(($IsHTML)?'text/html':'text/plain')."\n"
    			."Content-Transfer-Encoding: 8bit\n\n"
.$mailbody .$message

« previous php.general (#162448) next »