0

Hi All,

Can anybody see why the following function is ignoring the plain text part of the multipart?

$attachment = chunk_split(base64_encode(file_get_contents($filetoattach)));
		//Let's start our headers
		$headers = "From: $from_name<" .$from_name . ">\n";
		$headers .= "Reply-To: <" . $from_name . ">\n"; 
		$headers .= "MIME-Version: 1.0\n";
		$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
		$headers .= "X-Sender: $from_name<" . $from_name . ">\n";
		$headers .= "X-Mailer: PHP5\n";
		$headers .= "X-Priority: 1\n"; //1 = Urgent, 3 = Normal
		$headers .= "Return-Path: <" . $from_email . ">\n"; 
		$headers .= "This is a multi-part message in MIME format.\n";
		$headers .= "------=MIME_BOUNDRY_main_message \n"; 
		$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n"; 
		
		$message = "------=MIME_BOUNDRY_message_parts\n";
		$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; 
		$message .= "Content-Transfer-Encoding: 7bit\n\n";
		$message .= "\n"; 
		/* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
		$message .= $body."\n";
		$message .= "\n"; 
		
		
		$message = "------=MIME_BOUNDRY_message_parts\n";
		$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; 
		$message .= "Content-Transfer-Encoding: 7bit\n\n";
		$message .= "\n"; 
		/* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
		$message .= $html."\n";
		$message .= "\n"; 
		$message .= "------=MIME_BOUNDRY_message_parts--\n"; 

		$message .= "\n"; 
		$message .= "------=MIME_BOUNDRY_main_message\n"; 
		$message .= "Content-Type: application/pdf;\n\tname=\"" . $filetoattach . "\"\n";
		$message .= "Content-Transfer-Encoding: base64\n";
		$message .= "Content-Disposition: attachment;\n\tfilename=\"" . $filetoattach . "\"\n\n";
		$message .= $attachment; //The base64 encoded message
		$message .= "\n"; 
		$message .= "------=MIME_BOUNDRY_main_message--\n";
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by cereal
0

On line 24 you wrote $message = instead of $message .= This resets the variable and deletes what was previously stored. Bye.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.