我有这个 php 代码来发送 HTML 电子邮件:
function sendEmail($to,$from,$subject,$body) {
$To = $to;
$Subject = $subject;
$Message = $body;
$from = "Do Not Reply";
$Headers = "From: sender@taskmanager.domain.ca"." \r\n" .
"Reply-To: ".$from." \r\n" .
'MIME-Version: 1.0' . "\r\n".
'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($To, $Subject, $Message, $Headers);
}
function sendEmailUser($fromUserObj, $userInfo){
$html="
<html>
<body>
<p>
Dear ".$userInfo["firstName"] ." ".$userInfo["lastName"]." ,</p>
<p>
Welcome to IT .</p>
<p>
Account Information:</p>
<p>
Username:".$userInfo["username"]."</p>
<p>
Password: ".$userInfo["password"]."</p>
<p>
You can login <a href = 'http://domain.com'>here</a> .</p></body>
</html>";
$subject = "subject";
sendEmail($userInfo["email"], $subject, $html);
}
我收到电子邮件的普通文本,没有解释 html。
<html> <body> <p> Dear test lastname ,</p> <p> Welcome to IT.</p> ... </html>
我的代码有什么问题??请任何帮助,我将不胜感激。