我正在尝试发送包含一些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
所以我想在发送
之前,drupal会过滤HTML