php邮件功能不工作回复SMTP服务器响应:503


php mail function not working reply SMTP server response: 503

我尝试使用php邮件功能发送邮件。但我得到的错误像:

PHP Warning:  mail(): SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server. in C:'Inetpub'vhosts'qubedns.co.in'httpdocs'Codes'design'rnp'mailsend.php on line 21

这是我的PHP脚本:

<?php
$toEmail    = 'bikash336@gmail.com';
$subject    = 'hello';
$message    = 'Users are able to send emails to local domains and addresses but are unable to send email to any external address.';
$headers    = "MIME-Version: 1.0" . "'r'n";
$headers    .= "Content-type:text/html;charset=UTF-8" . "'r'n";
$headers    .= 'From: <sales@leonwallet.com>' . "'r'n";
$Status = mail($toEmail,$subject,$message,$headers);
if($Status){
    echo '1';
}else{
    echo '0';
}
?>

以下是我的服务器配置:http://qubedns.co.in/codes/php/

我怎么了?

我已经找到了PHPMailer的解决方案。这对我很有用。

<?php
require('mailserver/PHPMailerAutoload.php');
require('mailserver/class.phpmailer.php');
require('mailserver/class.smtp.php');
require('mailserver/class.pop3.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet="UTF-8";
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->IsHTML(true);
$mail->Username = 'sales@leonwallet.com';
$mail->Password = 'password';
$mail->From = 'sales@leonwallet.com';
$mail->FromName = 'Leon Sales Team';
$mail->AddAddress($to);
$mail->AddReplyTo('sales@leonwallet.com', 'Leon Sales Team');
$mail->Subject = $sub;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = $message;
if(!$mail->Send()){
  echo "1"; // ERROR
}else{
  echo "0"; // SUCCESS
}
?>

这里有一个解决方案。对我来说,他解决了的问题

当我更改环境时,TO参数是用我的测试/开发项目的域配置的。我将TO电子邮件更改为生产电子邮件,错误消失了。

以下是解决方案:http://www.marathon-studios.com/blog/php-mail-503-error/