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


                         メールアドレス
                        testl@gmail.com


                         電話番号
                        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.)

0

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

  • @Aniket i have check that – amol Jul 1 '16 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'; – Ankit Chauhan Jul 1 '16 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.

  • I have already check that . – amol Jul 1 '16 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, privacy policy and cookie policy

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