msg_subscribe.txt in html

kjmm

New Member
what is need to make sending the following messages in html? and have the possibility to customize them???

$msg_subscribe = LoadFileContentsAsText( $path_to_templates . "/" . $lang . "/msg_subscribe.txt" );
$msg_confirmation = LoadFileContentsAsText( $path_to_templates . "/" . $lang . "/msg_confirmation.txt" );
$msg_unsubscribe = LoadFileContentsAsText( $path_to_templates . "/" . $lang . "/msg_unsubscribe.txt" );


tks :)
 

stanbusk

Administrator
Staff member
You have to redesign the sendmessage() function so it can handle HTML.

For example I created a function called 'SendOffer' that alows you to send HTML emails. It is called this way:
Code:
SendOffer( $first_name, $last_name, $payer_email, $subject, $htmlfilename, "html", $headers, "utf-8" );

and this is the code of the function:
Code:
function SendOffer( $first_name, $last_name, $email_address, $subject, $offer, $format, $headers, $encoding ) {
	global $return_path_addr, $script_name, $script_version;
	
	// $offer  -> The offer full name with extention
	// $format -> The message format, 'html' or 'text' so we can set the headers accordingly
	
	$filename = "post_sale_offers/" . $offer;
	
	if ( file_exists( $filename ) && stristr( $email_address, "@" ) !== FALSE ) {

		$filehandle = fopen($filename, "r");
		
		if ($filehandle) {
		
			$message = "";
			while (!feof($filehandle)) {
	       		$message .= fgets($filehandle, 4096);
	   		}
	   		fclose($filehandle);
		
			$message = str_replace( "\r", "\r\n", $message ); // Replace all '\r' with '\r\n' in $message
	
			$key = strtoupper( md5( uniqid( microtime() ) ) );
			$key = substr( $key, 1, 8 ) . "-" . substr( $key, 9, 4 ) . "-" . substr( $key, 13, 4 ) . "-" . substr( $key, 17, 4 ) . "-" . substr( $key, 20, 12 );
			$host = getthehostname( $_SERVER['HTTP_HOST'] );
			$messageid = "<" . $key . "@" . $host . ">";
			
			$temp = $headers;		
	
			$headers  = "Return-Path: $return_path_addr\r\n";
			$headers .= "Message-ID: $messageid\r\n";
			$headers .= "Mime-Version: 1.0\r\n";
			$headers .= $temp . "\r\n";
			$headers .= "Date: " . date( DATE_RFC822 ) . "\r\n";
			$headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; //$script_name/$script_version\r\n";
	
			if ( $encoding <> "" ) {
				if ( $format == "html" ) {
					$headers .= "Content-Type: text/html; charset=$encoding\r\n";
				} else {
					$headers .= "Content-Type: text/plain; charset=$encoding; Format=flowed\r\n";
				}
				$headers .= "Content-Transfer-Encoding: 8bit";
			} else {
				//if ( $format == "html" ) {
					//$headers .= "Content-Type: text/html; charset=us-ascii\r\n";
				//} else {
					//$headers .= "Content-Type: text/plain; charset=us-ascii; Format=flowed\r\n";
				//}
				//$headers .= "Content-Transfer-Encoding: 7bit";
			}
			
			$full_address = "$first_name $last_name <$email_address>";
		
			$result = @mail($full_address, $subject, $message, $headers);
			if ( !$result ) { LogDeliveryError($full_address, $subject, $message, $headers); }
			
		}
	
	}
		
}
 
Top