2

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

如果我将电子邮件 ID 设置为xxx@company.netxxx@gmail.com ,我会从该表单收到电子邮件,但如果我将其设置为xxx@company.com ,那么我没有收到任何来自联系我们表单的邮件...

谁能帮忙解决这个问题?

Outlook 中所需的任何设置,例如 gmail,我们必须将其设置为“安全性较低”?

4

1 回答 1

0

您也应该使用标头,或者您也可以使用 PHPMailer/SMTP ( https://github.com/PHPMailer/PHPMailer )

$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";
}
于 2018-07-30T07:12:17.137 回答