The email body in defined in PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY(string) in a .ini file. It is plain text.
PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY= "Welcome to join XXXXXXXXXX %s %s %s %s %s"
I would like to know where I can add my css code in order to set the font-family of the email.
This is where the system construct the email. I not sure whether I should modify this file.
// Compute the mail body.
$emailBody = JText::sprintf(
'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY',
$user['name'],
$this->app->get('sitename'),
JUri::root(),
$user['username'],
$user['password_clear']
);
$mail = JFactory::getMailer()
->setSender(
array(
$this->app->get('mailfrom'),
$this->app->get('fromname')
)
)
->addRecipient($user['email'])
->setSubject($emailSubject)
->setBody($emailBody);
if (!$mail->Send())
{
$this->app->enqueueMessage(JText::_('JERROR_SENDING_EMAIL'), 'warning');
}
I think str_replace will do a trick
$new_body=str_replace("<body>","<body style='font-family:Georgia, Serif !important'",$email_body);
->addRecipient($user['email'])
->setSubject($emailSubject)
->setBody($new_body);
I found the solution. We need to first convert the plain text to HTML, then anything works.
$mail->isHTML(TRUE);
$html= array();
$html[] = '<div style="background: red">.$emailBody.</div>';
$mail->setBody(implode("
", $html));
$mail->Send();
Use div tag to wrap the email body text and apply CSS to div tag.