我遇到的问题是如何制作用户在我们网站上注册后获得的自动激活电子邮件是" HTML格式" 而不是& #34;纯文本格式" 。我几乎不知道该做什么或在哪里研究。
答案 0 :(得分:0)
您可以使用PHP mail()
功能在服务器上设置电子邮件后发送电子邮件。
要让mail()
发送html格式的电子邮件,您需要在电子邮件的标题中设置内容类型和字符集。
下面的内容取自php.net, here,这是了解mail()
函数和php的一般资源。
<?php
// Multiple recipients
$to = 'johny@example.com, sally@example.com'; // note the comma
// Subject
$subject = 'Birthday Reminders for August';
// Message
$message = '
<html>
<head>
<title></title>
</head>
<body>
<!-- content -->
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
// Additional headers
$headers[] = 'To: Mary <mary@example.com>, Kelly <kelly@example.com>';
$headers[] = 'From: Birthday Reminder <birthday@example.com>';
$headers[] = 'Cc: birthdayarchive@example.com';
$headers[] = 'Bcc: birthdaycheck@example.com';
// Mail it
mail($to, $subject, $message, implode("\r\n", $headers));
?>