Changing the msg_confirmation.txt to html.

Saul

New Member
Hello there.

I'm trying to change the confirmation message from .txt to .html .
I did went to lm.php and changed in line 562 the msg_confirmation.txt to msg_confirmation.html.

When I tested it didn't worked. The automatic email saws only the raw html code.

Please can you suggest something more?
Thank you very much.
 

Saul

New Member
Saul said:
Hello there.

I'm trying to change the confirmation message from .txt to .html .
I did went to lm.php and changed in line 562 the msg_confirmation.txt to msg_confirmation.html.

When I tested it didn't worked. The automatic email saws only the raw html code.

Please can you suggest something more?
Thank you very much.

Anyone? It is very important in order to build somthing extraordinary using MLM of MaxProg.
 

stanbusk

Administrator
Staff member
You also need to add HTML headers so the mail client are aware the message is HTML. It is not as easy as changing text with HTML code. By the way, why do you want to do that?
 

Saul

New Member
stanbusk said:
You also need to add HTML headers so the mail client are aware the message is HTML. It is not as easy as changing text with HTML code. By the way, why do you want to do that?

Please can you give a small example so I can understand more clear the HTML headers? Do I need to manipulate anything in the .php files?

I want to do that so the experience of the user (subscriber or unsubscriber) will be more pleasant. The .txt files are really great for start and efficient, but I want to push it more.

Thank you very much.
 

stanbusk

Administrator
Staff member
The following is a PHP function I use to send offers using HTML files. $filename is the path of that HTML file. I call it for example this way: SendOffer( "Stan", "Busk", "stanbuskadrrhere", "Other email products that may interest you...", "mbm_20120725.php", "html", $headers, "utf-8" );

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 fine 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); }
			
		}
	
	}
		
}
 

Saul

New Member
stanbusk said:
The following is a PHP function I use to send offers using HTML files. $filename is the path of that HTML file. I call it for example this way: SendOffer( "Stan", "Busk", "stanbuskadrrhere", "Other email products that may interest you...", "mbm_20120725.php", "html", $headers, "utf-8" );

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 fine 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); }
			
		}
	
	}
		
}

!!! extremely useful info. THANK YOU.
Now, where do you put this function?
 

Saul

New Member
stanbusk said:
In the lm_functions.php file

I prepared and put it in the end of lm.functions.php this (I use your name just for example). Is it ready for use? This will do to send the html confirmation message? :


function SendOffer( $Stan, $Busk, [email protected], $Subscription completed, $msg_confirmation.html, $html, $headers, $utf-8 ) {
   global $return_path_addr, $script_name, $script_version;
   
   // $offer  -> The offer full file name with extension
   // $format -> The message format, 'html' or 'text' so we can set the headers accordingly
   
   $filename = "post_sale_offers/" . $msg_confirmation.html;
   
¬† ¬†if ( file_exists( $filename ) && stristr( [email protected], "@" ) !== 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 = "$Stan $Busk <[email protected]>";
      
         $result = @mail($full_address, $Subscription completed, $message, $headers);
         if ( !$result ) { LogDeliveryError($full_address, $Subscription completed, $message, $headers); }
         
      }
   
   }
      
}
 

stanbusk

Administrator
Staff member
You have to maintain the function parameters:

function SendOffer( $first_name, $last_name, $email_address, $subject, $offer, $format, $headers, $encoding )
 

Saul

New Member
stanbusk said:
You have to maintain the function parameters:

function SendOffer( $first_name, $last_name, $email_address, $subject, $offer, $format, $headers, $encoding )

Thank you. I think I got it this time. So now:
1) Put it on functions.php
2) In lm.php make msg_confirmation.txt to msg_confirmation.html
3) ?

Thanks again.

-----------
// This function send html confirmation
function SendOffer( $Stan, $Busk, [email protected], $Subscription completed, $msg_confirmation.html, $html, $headers, $utf-8 ) {
   global $return_path_addr, $script_name, $script_version;
   
   // $offer  -> The offer full file name with extension
   // $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); }
         
      }
   
   }
      
}
 

Saul

New Member
stanbusk said:
Call this function rather than the other one to send the HTML message.

Thank you for your answer. You're saying:

lm_functions.php -> line 1264:

// Send a confirmation message to the subscriber
function SendSubscriptionMessage() {...........


-> replace this function with the one you gave me?
 

stanbusk

Administrator
Staff member
Not the function itself but the call to it. Where you want to send HTML call the new function instead of the default one.
 

Saul

New Member
stanbusk said:
Not the function itself but the call to it. Where you want to send HTML call the new function instead of the default one.

Forgive me for the total lack of knowledge.

So the default call is in the line 1395 in lm_functions.php, and I must call the new function, instead of that in line 1395, in order to send my html.

1) Where should I put the new function?
2) How can I do this ,html file default like the .txt?

Multi thank you.
 

stanbusk

Administrator
Staff member
Place the new function anywhere in the 'lm_functions.php' file. It has to be in that file. Then, where needed, just call it instead of the default one.
 

Saul

New Member
stanbusk said:
Place the new function anywhere in the 'lm_functions.php' file. It has to be in that file. Then, where needed, just call it instead of the default one.

Thanks a lot for your try and time, but I give up. I don't have the knowledge. I will leave the .txt files to work as automatic messages.
 
Top