简体   繁体   中英

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

I was writting a PHP mail script as follows

<?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");
   }


}

?>

But when executing found following warning message:

Warning: mail() [function.mail]: SMTP server response: 530 Relaying not allowed - sender domain not local in D:\\inetpub\\vhosts\\interactiveentertainmentstudios.com\\httpdocs\\sendmail.php on line 31 The email has failed!

Please let me know what to do??

To solve this problem you need create mail id from your current domain eg info@example.com and use in your mail function

 <?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.";
} ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM