0
我已經創建了重置密碼頁,在哪裏使用進入hes電子郵件,PHP發送給他一個重置密鑰。郵件的作品,但它在我的Gmail帳戶中的純文本。我希望它能用HTML。PHP的HTML郵件不工作,因爲我想
$subject = "Your password reset for {$config['site_name']}";
$message = "<html><body>";
$message .= "<p>Someone on" . $config['site_domain'] . "tried to reset your password.</p>";
$message .= "<p>Please click below link, if you want to reset your password.</p>";
$message .= "<p><a href='" . $config['site_url'] . "/forgot_password.php?key=" . $key . "'>" . $config['site_url'] . "/forgot_password.php?key=" . $key . "</a></p>";
$message .= "<p>Thank you,<br>The Admin - " . $config['site_url'] . " </p>";
$message .= "</body></html>";
// Create email headers
// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
// Additional headers
//$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= "From: " . $config['site_name'] . " <[email protected]" . $config['site_domain'] . "> \r\n";
$headers .= "X-Sender: <[email protected]" . $config['site_domain'] . "> \r\n";
$headers .= "Reply-To: <[email protected]" . $config['site_domain'] . "> \r\n";
mail($input['email'],$subject,$message,$headers);
//update pw_reset field into DATABASE
$stmt = $mysqli->prepare("UPDATE members SET pw_reset = ? WHERE email = ?");
$stmt->bind_param("ss", $key, $input['email']);
$stmt->execute();
$stmt->close();
與其他電子郵件供應商有什麼關係? – 2012-07-29 05:28:07
我個人喜歡'Zend_Mail'。做我需要做的一切。 – 2012-07-29 05:50:12
我喜歡phpmailer這種事情。它自動處理生成多部分電子郵件消息。如果您使用普通郵件(),那麼您必須自己編寫標題和分隔符:P(並且您確實需要執行多部分內容,因爲您不想將HTML電子郵件發送給僅設置爲獲取純文本的人)。 – octern 2012-07-29 06:01:25