5

In Admin > Email Configuration, I set “Default Mail Format” to “HTML”. Then I went to Design > Message Pages > Email Notifications and entered the following code into the “Member Account Activation Instructions” template:

<html>
 <head>
  <title>{site_name} Member Account Activation</title>

  <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />

  <style type="text/css">
   .list a {
    color: #cc0000; 
    text-transform: uppercase; 
    font-family: Verdana; 
    font-size: 11px; 
    text-decoration: none;
   }
   p {
    color: #3e3f3a; 
    font-family: Verdana; 
    font-size: 13px; 
    line-height: 20px;
   }
   h1 {
       color: #850d6f; 
       font-family: Verdana; 
       font-size: 16px; 
       font-weight:normal;
   }
   a:link, a:visited {
    color: #4a94ad;
   }
  </style>
 </head>

 <body marginheight="0" topmargin="0" marginwidth="0" bgcolor="#fff" leftmargin="0">
  <table border="0" cellspacing="0" cellpadding="0" width="600">
   <tr>
    <td bgcolor="#850d6f" height="72">
     <img src="{site_url}/images/email/logo_03.png" width="121" height="40" alt="Logo 03">
    </td>
   </tr>
   <tr>
    <td>
     <h1>Thank you for your new member registration.</h1>

     <p>To activate your new account, please visit the following URL:</p>

     <p>{unwrap}{activation_url}{/unwrap}</p>

     </p>Thank You!</p>

     <p>--<a href="{site_url}">{site_name}</a></p>
    </td>
   </tr>
  </table>

  <!-- footer -->
  <table cellspacing="0" border="0" height="202" cellpadding="0" width="600">
   <tr>
    <td class="copyright" height="100" align="center" valign="top" width="600" colspan="2">
     <br>
    &copy; <a href="{site_url}">{site_url}</a><br>
     <a href="{site_url}contact-us">Contact Us</a> | <a href="{site_url}privacy-policy-and-terms-of-use">Privacy Policy and Terms of Use</a>
    </td>
   </tr>
  </table>
 </body>
</html>

But when I do a test member registration, the email received is in plain text (the HTML code is visible as text). The content-type of the email is “text/plain”.

HTML email sent via the Communication panel is sent correctly with a content-type of “multipart/alternative”.

HTML email sent with MX Notify Control is also sent with the correct content-type.

8

I've just had a quick look at the source code and my impression is that EE doesn't currently support HTML-formatted activation emails. Here's the relevant bit of the EE source:

$this->email->EE_initialize();
$this->email->wordwrap = TRUE;
$this->email->from($this->config->item('webmaster_email'), $this->config->item('webmaster_name'));  
$this->email->to($row['email']);
$this->email->subject($this->functions->var_swap($template['title'], $swap));   
$this->email->message(entities_to_ascii($this->functions->var_swap($template['data'], $swap)));     
$this->email->send();

In order to send out HTML-formatted messages the mailtype property has to be set. In this instance it isn't even referenced, so the default behaviour (plain text) is used.

Changing this should just be a matter of inserting the line below, however I wouldn't recommend doing so as you'd inevitably forget about it in an update and users would start to wonder why they're being sent raw HTML when they register.

$this->email->mailtype($this->config->item('mail_format'));

Since this would be a single-line code change you could always submit a feature request. That said, if this is something you need in a reasonable timescale an add-on is probably the way to go.

  • I am trying to do the same thing. What file does this code get added to? – mediapimp Feb 8 '16 at 15:03
2

As far as i know, specialty templates are not sent as html. maybe use something like http://madebyhippo.com/addons/view/libraree?

1

Based on @Dom Stubbs' answer I created this extension to workaround this.

https://github.com/cld-agency/ee-html-email

Please note that if you are using any Freeform notifications, they will also need to be formatted with HTML, since this is a system-wide change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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