2

I have a joomla site with Kunena installed on it. My users are not happy with the layout of the email sent to them from the forum.

Here is part of the code that is responsible for creating this email:

protected function createEmailBody($subscription, $subject, $url, $message, $once) {
    $config = KunenaFactory::getConfig();
    if ($subscription) {
        $msg1 = $this->get ( 'parent' ) ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1_CAT' );
        $msg2 = $this->get ( 'parent' ) ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2_CAT' );
    } else {
        $msg1 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD1' );
        $msg2 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD2' );
    }

    $msg = $msg1 . " " . $config->board_title . "\n\n";
    // DO NOT REMOVE EXTRA SPACE, JMailHelper::cleanBody() removes "Subject:" from the message body
    $msg .= JText::_ ( 'COM_KUNENA_MESSAGE_SUBJECT' ) . " : " . $subject . "\n";
    $msg .= JText::_ ( 'COM_KUNENA_CATEGORY' ) . " : " . $this->getCategory()->name . "\n";
    $msg .= JText::_ ( 'COM_KUNENA_VIEW_POSTED' ) . " : " . $this->getAuthor()->getName('???', false) . "\n\n";
    $msg .= "URL : $url\n\n";
    if ($config->mailfull == 1) {
        $msg .= JText::_ ( 'COM_KUNENA_MESSAGE' ) . " :\n-----\n";
        $msg .= $message;
        $msg .= "\n-----\n\n";
    }
    $msg .= $msg2 . "\n";
    if ($subscription && $once) {
        if ($this->parent) {
            $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_READ' ) . "\n";
        } else {
            $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_SUBSCRIBE' ) . "\n";
        }
    }
    $msg .= "\n";
    $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION3' ) . "\n";
    return JMailHelper::cleanBody ( $msg );
}

So I decided to add an image as of the logo from my site to it at the bottom like this:

$msg .= ('<img src="http://mysite.me.ke/templates/jsn_nuru_free/images/colors/red/logo.png" width="100"/>');

butwhen the email was sent it returned the same thing I gave it

 <img src="http://mysite.me.ke/templates/jsn_nuru_free/images/colors/red/logo.png" width="100"/>

so I thought I should use htmlspecialchars_decode() php function as in:

$msg .= htmlspecialchars_decode('<img src="http://mysite.me.ke/templates/jsn_nuru_free/images/colors/red/logo.png" width="100"/>');

But still I got nothing new. Kindly help me out!

1

2 Answers 2

1

I would suggest using JUri::root() when defining the path of your site, like so:

$msg .= '<img src="' . JUri::root() . 'templates/jsn_nuru_free/images/colors/red/logo.png" width="100"/>';

In addition to this, I've removed the brackets you added outside the image tag as they're not required

3
  • No I didnt ask you to remove anything on my examples because they are right, what is not working right now is the html attributes like <H1>, <b>, <table> all those are not working tell me how html attributes can be passed to an email message
    – Jack Siro
    Commented Mar 3, 2015 at 3:36
  • 1
    Lodder is only trying to help you... Also, he is right about removing the brackes. Take a look at how to send html emails here: docs.joomla.org/Sending_email_from_extensions Commented Apr 1, 2015 at 15:58
  • @JacksonSiro - Check the revision history and you'll notice I haven't touched any of your examples
    – Lodder
    Commented Nov 14, 2016 at 17:12
1

Hey Jack if you could try using JUri::root() when defining the path of your site, like so:

   protected function createEmailBody($subscription, $subject, $url, $message, $once) {
        $config = KunenaFactory::getConfig();
        if ($subscription) {
            $msg1 = $this->get ( 'parent' ) ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1_CAT' );
            $msg2 = $this->get ( 'parent' ) ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2_CAT' );
        } else {
            $msg1 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD1' );
            $msg2 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD2' );
        }

        $msg = $msg1 . " " . $config->board_title . "\n\n";
        // DO NOT REMOVE EXTRA SPACE, JMailHelper::cleanBody() removes "Subject:" from the message body
        $msg .= JText::_ ( 'COM_KUNENA_MESSAGE_SUBJECT' ) . " : " . $subject . "\n";
        $msg .= JText::_ ( 'COM_KUNENA_CATEGORY' ) . " : " . $this->getCategory()->name . "\n";
        $msg .= JText::_ ( 'COM_KUNENA_VIEW_POSTED' ) . " : " . $this->getAuthor()->getName('???', false) . "\n\n";
        $msg .= "URL : $url\n\n";
        if ($config->mailfull == 1) {
            $msg .= JText::_ ( 'COM_KUNENA_MESSAGE' ) . " :\n-----\n";
            $msg .= $message;
            $msg .= "\n-----\n\n";
            $msg .= '<img src="' . JUri::root() . 'templates/jsn_nuru_free/images/colors/red/logo.png" width="100"/>';
        }
        $msg .= $msg2 . "\n";
        if ($subscription && $once) {
            if ($this->parent) {
                $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_READ' ) . "\n";
            } else {
                $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_SUBSCRIBE' ) . "\n";
            }
        }
        $msg .= "\n";
        $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION3' ) . "\n";
        return JMailHelper::cleanBody ( $msg );
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.