I am facing an unexpected issue with a PHP mail
function. The script sending email to all email address but not to my domain.
Suppose I send email to nitinsoni@gmail.com
it was received but when I send email to nitin@mydomain.com
it was not received.
I am using GoDaddy web hosting and PHP mail
function. SMTP is also not working on GoDaddy server.
PHP code is as follows:
<?php
$to = 'nitin@mydomain.com';
//$to = 'nitinsonitest@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: nitinsonitest@gmail.com' . "\r\n" .
'Reply-To: nitinsonitest@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$r = mail($to, $subject, $message, $headers);
if($r) {
echo 'mail sent';
}else {
echo 'not sent';
}
die;
?>
And SMTP email via PHPMailer
is not working as well:
<?php
echo "<pre>";
//die('ada');
require 'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->Host = "relay-hosting.secureserver.net"; // your SMTP Server
$mail->IsSMTP();
$mail->PORT = 465;
$mail->SMTPDebug=true;
$mail->SMTPAuth = true; // Auth Type
$mail->SMTPSecure = "ssl";
$mail->Username = "user@gmail.com";
$mail->Password = "password";
$mail->Sender = "user@gmail.com";
$mail->From = "user@gmail.com";
$mail->AddReplyTo("user@gmail.com");
$mail->FromName = "user ";
$mail->AddAddress("recepient@gmail.com");
$mail->IsHTML(true);
$mail->Subject = "Test subject";
$mail->Body='Test Subject';
$mail->WordWrap = 50;
if($mail->Send())
{
echo"<script>alert('The Form has been posted ,Thank you');</script>";
}
else
{
echo 'mail error';
}