I am facing a strange error when I execute a php mail script. Its related to server could not verify the sender. I see following error:
Failed to add recipient email@domain.com [SMTP: Invalid response code received from server (code:550, response: Verification failed for unrouteable address Sendor verify failed)]

Would you know why this error could pop up?

<?php
require_once "Mail.php";
$kw = (string)$_GET['keyword'];
$e = (string)$_GET['emailid'];
$uname="xxx";
$password="xxx";
$con=mysql_connect("Localhost","root","");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("mysql_db",$con);

mysql_query("INSERT INTO mail_alert (uname,emailid,password,keyword)values('$kw','$e','$uname','$password')");

/*$qry="select * from email_alert WHERE emailid='$e'";
$result=mysql_query($qry)or die("Couldn't execute query");
while ($row=mysql_fetch_array($result))
{
$kyw = $row["keyword"];
$email=$row["emailid"];
//echo $kyw;
// echo $email;
}*/

/*$to = 'email@domain.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From:mail.domain.com' . "\r\n" ;

mail($to, $subject, $message, $headers);
echo "mail has been sent";*/


/*$to = $e;
$subject = "Contact Us";
$email = "mail.domain.com";
$message = "hdfhdgf";
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent) {
print "Your mail was sent successfully";
} else
{

print "We encountered an error sending your mail";
}
*/


$from = "mail.domain.com";
$to = $e;
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://domain.com";
$port="465";
$username = "login";
$password = "xxx";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp =Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}


mysql_close($con);

?>

It is a verification problem. Are you sure that the username shouldn't be your e-mail address ? If not, ask your system administrator.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.