繁体   English   中英

PHP邮件功能只能回复Gmail帐户,非Gmail帐户则不能

[英]PHP mail function only can reply to Gmail account, but not for non-Gmail account

可以将我发布在我的域中的用户消息发送到我的Web邮件,但随后用户将无法接收该用户发送到其电子邮件地址的消息副本。 除此之外,我的Webmail可以将邮件回复到用户的电子邮件地址,但是只有gmail帐户可以在垃圾邮件文件夹中收到我的回复,但是yahoo和hotmail帐户没有从我的webmail收到任何回复消息。 起初,yahoo帐户仍可以接收来自Webmail的消息副本和回复消息。 但是现在完全不能。 我能知道是什么问题吗? 感谢您的帮助!

<?php
 session_start();
 include("functions/functions.php");
?>
<?php 
if(isset($_POST['submit'])){

    $ip = getIP();

    $userName= $_POST['userName'];
    $phoneNumber= $_POST['phoneNumber'];
    $email= $_POST['email'];
    $message= $_POST['message'];
    $currentdatetime=date('Y-m-d');

if(empty($userName)||empty($phoneNumber)||empty($email)||empty($message))
    {

        echo "<script type='text/javascript'>alert('All the fields must be filled in. Please try again.');";
 echo  "window.location.href='contact.php';";
 echo"</script>";
 exit();
    }

    else if (ctype_alpha(str_replace(' ', '', $userName)) === false) {
        echo "<script type='text/javascript'>alert('Name must only contain letters!');";
 echo  "window.location.href='contact.php';";
 echo"</script>";
 exit();
}



    else if(strlen($phoneNumber)<11 || strlen($phoneNumber)>12|| substr($phoneNumber, 3, 1)!='-')
    {

        echo "<script type='text/javascript'>alert('Phone Format is incorrect. Please use the following format: 01x-1234567');";
 echo  "window.location.href='contact.php';";
 echo"</script>";
 exit();
    }
    else if((strpos("$email","@")== 0)||  (strpos("$email",".com")== 0) )
    {
        echo "<script type='text/javascript'>alert('Email Format is incorrect.');";
 echo  "window.location.href='contact.php';";
 echo"</script>";
 exit();
 }

 else if($_POST['userName']!=''&& $_POST['phoneNumber']!='' && $_POST['email']!='' && $_POST['message']!='' ){



$to = "email@site.com"; // this is my Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['userName'];
$contact = $_POST['phoneNumber'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message ="Dear Sir/Madam,". "\n\n" ."New enquiry as below:" . "\n\n" ."Name:" .$name . "\n\n" . "Contact No: " . $contact. "\n\n" ."Email Address:". $from. "\n\n" ."Message/Enquiry:". $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers2 = "MIME-Version: 1.0" . "\r\n";
$headers2 .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "<script>alert('Mail Sent. Thank you " . $name . ", we will contact you shortly.')</script>";

}

//insert into databse
$insert_msg = "insert into msg(userName, phoneNumber, email, message, status, msg_date) values ('$userName', '$phoneNumber', '$email', '$message', 'Pending', '$currentdatetime')";
    $run_msg = mysqli_query($con, $insert_msg);
}

?>
<!DOCTYPE html>
<html>
<head>
</head>
<body> 
  <!--start-contact-->
  <div class="contact">
    <div class="container">
    <h3>CONTACT US</h3>
    <p>Please contact us for all inquiries and purchase options.</p>

    <form action='' method='POST'>
         <input type="text" name='userName' placeholder="NAME" required>
         <input type="text" name='phoneNumber' placeholder="PHONE NUMBER" required>          
         <input class='user' name='email' type="text" placeholder="EMAIL" required><br>
         <textarea name='message' placeholder="MESSAGE"></textarea>
         <input type="submit" name="submit" value="SEND">
    </form>
   </div>
   </div>
   <!--end-contact-->
 </body>
 </html>

您的代码看起来不错,却不知道include(“ functions / functions.php”)中包含什么;

我有一个类似的问题。 该错误可能来自多种原因:

1)如果您使用共享服务器,请与您的提供商联系,以查看是否有可能导致问题的原因,或者即使您有权发送电子邮件,也可以这样做。

2)如果您使用的是SMTP插件,请检查端口25、587、465、475和2525是否未阻塞。 这些端口是hotmail和其他公司用于处理电子邮件流量的端口,如果出于某种原因您的脚本不包括这些端口,或者出于安全原因阻止了它们,则您将遇到电子邮件问题。

我建议您通过SMTP仔细阅读

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM