Email Body with Html Code

Rafail Stratiotis Posted in Component Development 2 years ago

Hi Guys

Is there way to put a html code to make a body for mails sending " Registration" "Reset Password" etc... ???

Indonesian Arsalan Shah Replied 2 years ago

Hi Rafail, there is no demo as i already posted full code here,

  1. Create a folder called MyMailer
  2. Create file called ossn_com.php add the code inside it from my first reply.
  3. Create a file called ossn_com.xml and add following code.
  4. Zip MyMailer folder you will get upload this component to your website and enable it.

Note that this component will just add <div>any message </div> that means you can change it or wrap message in your own html <div></div> is just example.

ossn_com.xml file

<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="">
    <author>Core Team</author>
    <description>My HTML mailer.</description>
    <license>Open Source Social Network License (OSSN LICENSE)</license>

Try to reset password and see if the message you receive is html?

gr Rafail Stratiotis Replied 2 years ago

can you give me a demo?
I may be doing something wrong...

Indonesian Arsalan Shah Replied 2 years ago

i am not sure what do you mean by T_string? there is no such a error for me, where did you get that error? on which line?

gr Rafail Stratiotis Replied 2 years ago

i can't do it i get error T_string is there any other way?

Indonesian Arsalan Shah Replied 2 years ago


You can use html template, just for example you can see that override current mailer just non-tested code:

ossncom.php file
function my
htmlmails() {
addhook('email', 'send:policy', 'myhtmlmailsdeny', 1);
addhook('email', 'send', 'myhtmlmailsextends', 1);
function myhtmlmails_extends($hook, $type, $mail, $return) {
$currentText = nl2br($mail->Body);

            $mail->Body     = "<div>{$currentText}</div>"; //here you can wrap message in your html template

            $mail->Host     = $settings->host;
            $mail->Port     = $settings->port;
            $mail->Username = $settings->username;
            $mail->Password = $settings->password;
            return $mail->send();
function my_htmlmails_deny(){
        return false;
ossn_register_callback('ossn', 'init', 'my_html_mails');