Page 1 of 1

mime types send mail() error cannot open attachment

Posted: Sat Sep 13, 2003 5:21 pm
by kendall
Hello,

the following code submits a message with an image attached to it

Code: Select all

//get file
			$fp = fopen($DOCUMENT_ROOT.'/community/clubliquid/images/invis/invi.jpg',"r");
			$filename = fread($fp, filesize($DOCUMENT_ROOT.'/community/clubliquid/images/invis/invi.jpg'));
			$file = chunk_split(base64_encode($filename),60,'\n');
			fclose($fp);
			$mime_boundary = "<<<--==+X&#1111;".md5(time())."]";
			$headers .= "From: <".$SenderMail."> \n";
			$headers .= "To: <kendall@apex-solutions.com> \n";
			$headers .= "Message-ID: <".$mime_boundary."@oemcomputer> \n";
			$headers .= "MIME-Version: 1.0 \n";
			$headers .= "Content-Type: multipart/mixed; ";
			//$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
			//$headers .= "X-attachments: invi.jpg";
			$headers .= " boundary="".$mime_boundary.""; \n"; 
			$headers .= "Content-Transfer-Encoding: 7bit";
			$headers .= "This is a MIME Encoded message \r";
			$message .= "--".$mime_boundary." \r";
			$message .= "Content-Type text/plain; charset="iso-8859-1" \n";
			$message .= wordwrap($Message, 72)." \n";
			$message .= "--".$mime_boundary." \n";
			$message .= "Content-Type: image/jpeg; ";
			$message .= " name="invi.jpg" \r";
			//$message .= "Content-Type: application/x-image-jpeg; \r\n";
			$message .= "Content-Transfer-Encoding: base64 \r";
			$message .= "Content-Disposition: attachment; ";
			$message .= " filename="invi.jpg" \n"; 
			$message .= $file.' \n';
			$message .= "--".$mime_boundary."-- \n";
			mail('kendall@apex-solutions.com',$Subject,$message,$headers)&#123;
MY problem is i get an 'unknown file type' error when trying to open the attachement jpeg... i have checked with my server and i am able to do this feature....

Can anyoone offer any suggestions as to why i get this

Kendall