警告:mail()[function.mail]:SMTP服务器响应:550无效收件人:


Warning: mail() [function.mail]: SMTP server response: 550 Invalid recipient:

我正在创建一个"忘记密码"页面,用户在其中输入他们的电子邮件地址,脚本找到与该电子邮件相关的密码,并将其发送到存储的电子邮件地址。

我认为问题与我的SMTP邮件服务器有关。我使用的WAMP没有,所以我下载了一个免费的。

这是我正在使用的php脚本:

    $id = checkEmail($email);
    $record = readMemberRecord($id);
    $password = @mysql_result($record,0,'cred');
    if($password){
        $email_subject = "Email Request";
        $email_body = "Your password is ".$password.".";
        $header = "NinjaMan";
        mail($email, $email_subject, $email_body,$header);
        $msg = "Your password has been sent to ".$email.".";
    }else{
        $msg = "Sorry, the email ".$email." wasn't found.";
    }

$msg输出正确,所以我知道代码正在传递邮件函数。

尝试在$header中发送正确的"From"。

$emailFrom = "admin@yourdomain.com"; // match this to the domain you are sending email from
$email = "example@example.com";
$subject = "Email Request";
$headers = 'From:' . $emailFrom . "'r'n";
$headers .= "Reply-To: " . $email . "'r'n";
$headers .= "Return-path: " . $email;
$message = "Your password is ".$password.".";
mail($email, $subject, $message, $headers);

请参阅mail()函数的详细信息。

如果这不起作用,请尝试使用PHPMailer。您可以在代码中配置它,无需编辑php.ini。

我在一些项目中使用过它(2.0.4版本,我看到最新版本是5.1),没有任何问题。

尝试使用谷歌的服务器发送邮件,您可以在这里看到如何做到这一点

尝试使用此

//Email information
$to = "garggarima@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a test email message.";
$from = "support@sltechsoft.com";
$headers = "From:" . $from;
$mail=mail($to,$subject,$message,$headers);
if($mail) {
    echo "Thanks for mail";
} else {
    echo "Mail not Sent";
}
//Email response
echo "Thank you for contacting us!";