1

I'm editing the emails for Joomla so it looks a bit better Now I wanted to edit the registration email since it's just plain text I've found 2 files which have effect on the email:

com_users/models/registration.php
language/com_users.ini

Now I've been able to edit the text inside the email using the language file, but I would like to add an image the the email

I tried that in the PHP file: $emailBody =

                JText::sprintf(
                "<img style='width: 200px' src='imageurl'>
                <img src='imageurl'>".
            'COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY',
                $data['name'],
                $data['sitename'],
                $data['activate']
                $data['siteurl'],
                $data['username'],
                $data['password_clear']
            );

but this comes back as plain text Is it possible to set the email to HTML emails, so the HTML will be displayed?

  • You cannot pass html content/tags for JText::_ or JText::sprintf functions. Use JHtml fro html content. – Ravinder Reddy May 05 '16 at 18:10
  • That sounds logical, I tried it but I cant get it to work however. How would I use this if I only want to add the code there? I tried to change JText::sprintf into JHtml::sprintf which gives a blank page, JHtml::_ which gives an error 500, when I google it I cannot find any way to add regular HTML there – user2620358 May 05 '16 at 18:30
  • You have to import JHtml class first. For image use JHtml::image($args). Check this link https://docs.joomla.org/API16:JHtml/image – Ravinder Reddy May 05 '16 at 18:38

1 Answers1

1

I am not sure what exactly you are looking for, but you can check the below code if it works?

// include JHtml class
jimport( 'joomla.html.html' );

// for Image
$emailBody =JHTML::image($filepath, $alt);
// for text
$emailBody .=
JText::sprintf(
'COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY',
$data['name'],
$data['sitename'],
$data['activate'],
$data['siteurl'],
$data['username'],
$data['password_clear']
);

OR

$emailBody = "<img style='width: 200px' src='imageurl'>
            <img src='imageurl'>";
$emailBody .=
 JText::sprintf(
'COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY',
$data['name'],
$data['sitename'],
$data['activate'],
$data['siteurl'],
$data['username'],
$data['password_clear']
    );

Please use correct $filepath or scr for images.

Ravinder Reddy
  • 3,869
  • 1
  • 13
  • 22
  • I've tried both options, but in both situations it still only displays the code as plain text inside the email instead of HTML Im thinking maybe Joomla just doesnt support this option in their registration emails – user2620358 May 06 '16 at 12:47
  • 2
    can you show the code you are using to send email. enable htmlmode while sending email. $mailer->isHTML(true); OR JFactory::getMailer()->sendMail($from,$fromname,$buyerEmail, $subject, $body,true); – Ravinder Reddy May 06 '16 at 14:30
  • For sending emails with HTML code please check thes link http://stackoverflow.com/questions/20851830/mail-content-shows-as-html-code-in-joomla-3 – Ravinder Reddy May 06 '16 at 14:35