1

I am using the Swift mailer module to send HTML emails. My actual body in hook_mail_alter() is the following.

    <p><em><strong>New Enquiry Appear </strong></em></p>

<table border="1" cellpadding="1" cellspacing="1" height="77" width="467">
    <tbody>
        <tr>
            <td style="width: 228px;">お名前</td>
            <td style="width: 258px;">@name</td>
        </tr>
        <tr>
            <td style="width: 228px;">&nbsp;メールアドレス</td>
            <td style="width: 258px;">@email</td>
        </tr>
        <tr>
            <td style="width: 228px;">&nbsp;電話番号</td>
            <td style="width: 258px;">@mobile</td>
        </tr>
        <tr>
            <td style="width: 228px;">題名</td>
            <td style="width: 258px;">@title</td>
        </tr>
        <tr>
            <td style="width: 228px;">メッセージ本文</td>
            <td style="width: 258px;">@message</td>
        </tr>
    </tbody>
</table>

<p>&nbsp;</p>

The actual output is something like the following.

    /*New Enquiry Appear */

お名前
                        amol


                         メールアドレス
                        [email protected]


                         電話番号
                        99888776655


                        題名
                        challawar
               Html tag are not converted in Bold and Italic.


                        メッセージ本文
                        sssssssssssssssss

I want my output to be well formatted as per my HTML markup. (Few HTML tags like <br />, <strong>, and <table> are not working in the above example.)

3 Answers 3

0

Did you check the message setting of swiftmailer module? You can change the message format to HTML.

2
  • @Aniket i have check that
    – amol
    Jul 1, 2016 at 8:13
  • in mailsystem module setting, change the theme, then it should work. If it still not work, then try adding following code in your mail alter $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed; delsp=yes'; Jul 1, 2016 at 9:30
0

Please check the link module configuration link. It has option of sending email either as Plain Text or HTML. Please re-verify that settings.

1
  • I have already check that .
    – amol
    Jul 1, 2016 at 8:15
0

In .module file use the following code

use Drupal\Core\Render\Markup;

function hook_mail_alter(&$message) { 

$message['body'][1] = Markup::create($message['body'][1]);

}

Your Answer

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

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