成功消息-显示“电子邮件发送成功”,但我的gmail上没有收到电子邮件

时间:2018-09-13 05:31:34

标签: php email

我想在提交表单时在我的gmail上发送电子邮件。成功消息-“显示电子邮件发送成功”,但我没有在Gmail上收到任何电子邮件

以下是我用于在表单提交时发送电子邮件的代码。

if(isset($_POST["submit"])){
//Checking for blank Fields..
if($_POST["vname"]==""||$_POST["vemail"]==""||$_POST["sub"]==""||$_POST["msg"]==""){
echo "Fill All Fields..";
}else{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['vemail']; 

 // Sanitize e-mail address
 $email =filter_var($email, FILTER_SANITIZE_EMAIL);

 // Validate e-mail address
 $email= filter_var($email, FILTER_VALIDATE_EMAIL);

 if (!$email){
echo "Invalid Sender's Email";
 }
 else{
 $subject = $_POST['sub'];

 $message = $_POST['msg'];

 $headers = 'From:'. $email2 . "\r\n"; // Sender's Email
 $headers .= 'Cc:'. $email2 . "\r\n"; // Carbon copy to Sender

 // message lines should not exceed 70 characters (PHP rule), so wrap it
 $message = wordwrap($message, 70);

 // Send mail by PHP Mail Function
 mail("preetkaurpaik@gmail.com", $subject, $message, $headers);
 echo "Your mail has been sent successfuly ! Thank you for your feedback";
 }
}
}
?> 

4 个答案:

答案 0 :(得分:0)

您可能要检查垃圾邮件/垃圾文件夹。

有时,在新服务器上进行测试时,您的电子邮件服务提供商会自动过滤掉这些电子邮件。

如果这是问题所在,只需将发件人白名单/添加到批准的发件人中。

答案 1 :(得分:0)

我建议使用适当的SMTP client。依靠mail()并不是最佳实践,因为即使在开发过程中也可以看到这一点。

答案 2 :(得分:0)

检查您的垃圾邮件文件夹邮件是否已在Gmail中发送。您是否在本地系统中使用此代码?因此,请使用PHP Mailer。这是您的最佳做法。 https://github.com/PHPMailer/PHPMailer

答案 3 :(得分:0)

我认为问题可能是因为您没有设置变量 public sealed class ResponseKey : System.Tuple<System.Guid, string, string> { public ResponseKey(System.Guid item1, string item2, string item3) : base(item1, item2, item3) { } public System.Guid VenueId => Item1; public string ContentId => Item2; public string Answer => Item3; } ,请检查变量中是否包含有效的电子邮件。

也许可以尝试这样的操作,它告诉MUA的发件人地址和回复地址:

$email2
相关问题