php邮件警告-SMTP服务器响应:530不允许中继


php mail warning - SMTP server response: 530 Relaying not allowed

我正在编写一个PHP邮件脚本,如下

<?php
    if(isset($_REQUEST['txt_email'])&&isset($_REQUEST['message']))
    {
     if(filter_var($_REQUEST['txt_email'],FILTER_SANITIZE_EMAIL))
    $m=trim($_REQUEST['message']);
    $subject="Message From IES Web";
    $name=trim($_REQUEST['txt_name']);
    $web=trim($_REQUEST['txt_web']);
    $from=$_REQUEST['txt_email'];

    $to="rivu@gmail.com";
    $msg="<b>Name</b>".$name."<br /><b>Web</b>".$web."<br /><b>Message</b>".$m;
    $headers =  'MIME-Version: 1.0' . "'r'n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n"; 
    $headers .= "From: ".$from."'r'n";
    $headers .= "Reply-To: ".$from."'r'n";
    $headers .= "Return-Path:  ".$from."'r'n";

if ( mail($to,$subject,$message,$headers) ) {
   echo "The email has been sent!";
  // header("location: index.php?m_status=1");
   } else {
   echo "The email has failed!";
  // header("location: index.php?m_status=0");
   }

}
?>

但执行时发现以下警告消息:

警告:mail()[function.mail]:SMTP服务器响应:530正在中继不允许-发件人域不是本地域D: ''inetpub''vhosts''interactiveentertainmentstudios.com''httpdocs''sendmail.php第31行电子邮件失败!

请告诉我该怎么办??

要解决此问题,您需要从当前域创建邮件id,例如info@example.com并在您的邮件功能中使用

 <?php
 $to = 'rajagopalan@yourdomain.com';
 $res = mail($to, 'Testing mail', "This is a test'n'nEnd.", "From: $to");
 if ($res) {
echo "Message appears to have been accepted"; // does not mean it will be delivered
 } else {
echo "PHP mail() failed.";
} ?>