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";

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.