0

我正在尝试发送一封带有一些 HTML 的简单电子邮件,drupal_mail()正在发送电子邮件,但所有 HTML 似乎都已被删除。

$body = '<div style="width: 600px; margin: 0px auto">';
$body .= '<img align="center" src="' . $url . '" style="max-width: 600px; height: auto; margin: 0px auto">';
$body .= '<p style="margin: 30px 0px 0px 0px; line-height: 18px">' . nl2br($message) . '</p>';
$body .= '</div>';

params = array(
    'subject' => 'An e-card from HKUST',
    'body' => $body
);

if(drupal_mail('ecard', 'ecard_email', $single_email, language_default(), $params, $yourEmail, TRUE)) {
    echo 'Send';
}

function ecard_mail($key, &$message, $params) {
    $headers = array(
        'MIME-Version' => '1.0',
        'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
        'Content-Transfer-Encoding' => '8Bit',
        'X-Mailer' => 'Drupal'
    );
    foreach($headers as $key => $value) {
        $message['headers'][$key] = $value;
    };

    $message['subject'] = $params['subject'];
    $message['body'][] = $params['body'];
}

我在这里还缺少什么吗?

编辑:当我在 gmail 中查看电子邮件时,我可以看到:

X-PHP-Originating-Script: 381:system.mail.inc
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal

所以我猜HTML在发送之前被drupal过滤了

4

0 回答 0