user2620358 user2620358 - 4 months ago 21
Ini Question

Add an image to Joomla Registration email

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?

Answer

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.

Comments