Reputation: 1372
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="[email protected]";
$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??
Upvotes: 1
Views: 1344
Reputation: 321
To solve this problem you need create mail id from your current domain e.g [email protected] and use in your mail function
<?php
$to = '[email protected]';
$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.";
} ?>
Upvotes: 0