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

时间:2015-02-27 10:11:00

标签: php email

我正在编写如下的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 \虚拟主机\ interactiveentertainmentstudios.com \ httpdocs资料\ sendmail.php   第31行电子邮件失败了!

请让我知道该怎么做??

1 个答案:

答案 0 :(得分:0)

要解决此问题,您需要从当前域创建邮件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.";
} ?>