2

mail.php

 <?php    
function goback()
{ 
    header("refresh:5; url=index.php");
    exit;
}
if(isset($_POST['submit'])){

  $name = $_POST['name'];
  $comment = $_POST['comment'];
  $mob = $_POST['mob'];
  $email= $_POST['email'];

  $to ='xxx@company.net';
  $subject= 'Request callback form';
  $message ="Name: ".$name."\n".
            "Comment: ".$comment."\n".
            "Mobile: ".$mob."\n".
            "E-mail: ".$email;           


  if(mail($to, $subject, $message)){        
    echo "Sent successfully! Thank you. ".$name.
    ", We will contact you soon!";
    goback();
  }
else 
{
  echo "something went wrong";
}
}
?>

I am getting email from this form if I set email id to xxx@company.net or xxx@gmail.com, But if I set it to xxx@company.com then I didnt received any mail from contact us form ...

can anyone help to fix this?

any setting required in outlook like in gmail we have to set it to "less security" ??

Goli
  • 436
  • 5
  • 19

1 Answers1

0

you should use headers as well or you can use PHPMailer/SMTP (https://github.com/PHPMailer/PHPMailer) as well

$subject = 'Subject Here';
$from = 'From email';
$to = $email;       
$message = 'Your query has been successfully submitted';  

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: <$from>" . "\r\n";

$mail = mail($to,$subject,$message,$headers);

if($mail){
   echo  "Done";
}else{
   echo "error";
}
JustBaron
  • 2,319
  • 7
  • 25
  • 37
Rohit Guleria
  • 72
  • 1
  • 12