0
我試圖編寫腳本,以便在用戶使用PHP成功註冊時向用戶發送郵件。 用戶在數據庫中註冊成功,但未發送電子郵件。 這裏是我的代碼:成功註冊時發送郵件
<?php
function send_mail($id,$name,$email,$password)
{
$from='Admin <[email protected]>';
$headers = '';
$headers .= "From: $from\n";
$headers .= "Reply-to: $from\n";
$headers .= "Return-Path: $from\n";
$headers .= "Message-ID: <" . md5(uniqid(time())) . "@" . $_SERVER['SERVER_NAME'] . ">\n";
$headers .= "Date: " . date('r', time()) . "\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
}
$subject = "Welcome!";
$message = "
<p></p><br>
Hi ".$name."<br>
Thank you for registering for the event.<br><br>
Your ID is ".$id."<br>
Login using your email id : ".$email." and,<br>
your password : ".$password."<br><br>
";
mail($email,$subject,$message,$headers);
?>
在我register.php
劇本我已經包括:
send_mail($u_id,$u_name,$_POST['email'],$password)
函數的參數是id
(INT),name
(VARCHAR),email
(VARCHAR)& password
(VARCHAR)