<?phpinclude_once('conn.php');
$activationKey =  mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand(); 
$username = mysql_real_escape_string($_POST[username]); 
$password = mysql_real_escape_string($_POST[pwd]); 
$email = mysql_real_escape_string($_POST[email]); 
$sql="INSERT INTO users (username, password, email, activationkey, status) VALUES 
('$username', '$password', '$email', '$activationKey', 'verify')";echo "An email has been sent to $_POST[email] with an activation key. Please check your mail to complete registration."; 
//Send activation Email 
$to      = $_POST[email]; 
echo $to;
$subject = " hajin.com Registration"; 
$message = "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at hajin.com. You can complete registration by clicking the following link:\rhttp.//www.YOURWEBSITE.com/verify.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ hajin.com Team"; 
$headers = 'From: bigboylike@ sina.com' . "\r\n" . 
'Reply-To: [email protected]' . "\r\n" . 
'X-Mailer: PHP/' . phpversion(); 
mail($to, $subject, $message, $headers);
?>提示错误 Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command. in E:\WEB\goo\yx.php on line 20phpemail

解决方案 »

  1.   

    $to      = $_POST[email]; 收件人的值你赋予了吗?
    可以将 $to, $subject, $message, $headers 都echo 出来看看,是不是哪个值不对?
      

  2.   

    SMTP server response: 503 5.5.2 Need Rcpt command.
    SMTP服务器响应:5035.5.2需要RCPT命令。这说明,您的发件服务器需要用户验证(先登录、再发件)
    php 的 mail 函数只能用于不需要用户验证的发件服务器
      

  3.   

    如果不用mail函数 该使用什么插件?PHPMAILER吗?
      

  4.   

    必须要自动登录,PHPMAILER 当然是备选方案之一