I have a problem while sending a HTML email through my module, Here is my code below:
.install file
function invite_an_user_enable() {
$current = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
$addition = array('invite_an_user' => 'invite_an_userMailSystem');
variable_set('mail_system', array_merge($current, $addition));
}
function invite_an_user_disable() {
$mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
unset($mail_system['invite_an_user']);
variable_set('mail_system', $mail_system);
}
and here is the .module file:
class invite_an_userMailSystem extends DefaultMailSystem {
public function format(array $message) {
$message['body'] = implode("\n\n", $message['body']);
$message['body'] = drupal_wrap_mail($message['body']);
return $message;
}
}
Here is the email that I got:
<p>Hi <strong>[email protected]</strong>, </p>
<p>Your friend <strong>[email protected]</strong>, invited you in <strong>My Site Name</strong>. Please cleck on the link to accept the invitation below:</p>
<p>http://something.com/referral/3139323e</p>
<p> </p>
<p>Thanks,<br />
My Site</p>
Now the problem is that, when I received the email I can see all the tags in my email. And the header of the email is
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
I believe this should be text/html rather than text/plain. Am I doing something wrong? Is there any different method to send HTML mail? Feel free to ask any questions.