I have created my contact us module using form api, email is successfully generated and send to my specified email address, but I need body of the email to b html formatted, for this I have created another file mymodule.install in my module folder and add the below code:

function mymoduleenable() {
 $current = variable_get('mail_system', array('default-system' =>    'DefaultMailSystem'));
 $addition = array('mymodule' => 'mymoduleMailSystem');
 variable_set('mail_system', array_merge($current, $addition));

function mymoduledisable() {
 $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
 variable_set('mail_system', $mail_system);

and in my mymodule.module

 class mymoduleMailSystem extends DefaultMailSystem {
 public function format(array $message) {
 $message['body'] = implode("\n\n", $message['body']);
 $message['body'] = drupal_wrap_mail($message['body']);
 return $message;

but due to above all piece of code I am unable to receive email, kindly suggest any solution.

1 Answer 1


Same thing i do in my module may be it is set to you requirement

    global $content;
    $content .= '<button class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg">Apply</button>';
    $content .= '<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">';
    $content .= '<div class="modal-dialog modal-lg">';
    $content .= '<div class="modal-content">';
    $content .= drupal_render($form);
    $content .= '</div>';
    $content .= '</div>';
    $content .= '</div>';
    return $content;
  • $body[] = 'Name: '.$valid_name.'<br />Email: '.$valid_email.'<br />Quantity: '.$valid_quantity.'<br />Article: '.$valid_id.'<br />URL: '.request_uri(); @Adi, I am talking about this line, I need it to be html formatted when email is received
    – nomeer
    Nov 18, 2015 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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