Email Body with Html Code

rafail stratiotis Posted in Component Development 5 days ago

Hi Guys

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

Replies
German Arsalan Shah Replied 5 days 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 MyMailer.zip 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="http://www.opensource-socialnetwork.org/v/3.0">
    <name>MyMailer</name>
    <id>MyMailer</id>
    <author>Core Team</author>
    <description>My HTML mailer.</description>
    <license>Open Source Social Network License (OSSN LICENSE)</license>
    <author_url>https://www.softlab24.com/</author_url>
    <license_url>http://www.opensource-socialnetwork.org/licence</license_url>
    <version>5.0</version>
    <requires>
        <type>ossn_version</type>
        <version>5.0</version>
    </requires>
</component>

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

gr Rafail stratiotis Replied 5 days ago

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

German Arsalan Shah Replied 5 days 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 5 days ago

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

German Arsalan Shah Replied 5 days ago

UPDATED

You can use html template, just for example you can see https://github.com/opensource-socialnetwork/SMTP that override current mailer just non-tested code:

ossncom.php file
<?php
function my
htmlmails() {
ossn
addhook('email', 'send:policy', 'myhtmlmailsdeny', 1);
ossn
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->isHTML(true);
            $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');