email_api with HTML

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
dtamajon
Posts: 15
Joined: 13 Jun 2013, 23:08

email_api with HTML

Post by dtamajon »

I have done some modifications on core/email_api.php to accept html e-mails.

To do so, I have added the following parameter on config_inc.php

Code: Select all

$g_email_is_html                = ON; # or OFF for plain-text; default is OFF
And then update this function to distinguish between plain-text or HTML new line.

Code: Select all

/**
 * clean up LF to CRLF
 *
 * @param string $p_string
 * @return null
 */
function make_lf_crlf( $p_string ) {
	$t_string = str_replace( "\n", "\r\n", $p_string );
	$t_string = str_replace( "\r\r\n", "\r\n", $t_string );
	if ( ON == config_get( 'email_is_html' ) ) {
		$t_string = str_replace( "\r\n", "<br>", $t_string );
	}
	return $t_string;
}
At the time, the config parameter is used to define sort of mail.

Code: Select all

$mail->IsHTML( config_get( 'email_is_html' )  );
I have attached complete email_api.php modified with all newline changes required. I hope it can help someone!!
Attachments
email_api.txt
(50.35 KiB) Downloaded 670 times
Last edited by dtamajon on 14 Jun 2013, 08:17, edited 3 times in total.
atrol
Site Admin
Posts: 8553
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: email_api with HTML

Post by atrol »

Please use Search before posting and read the Manual
Post Reply