我知道这个问题已经被多次询问。我需要有人检查为什么该应用程序显示成功消息,但是我的邮件中没有收到任何邮件。这是我的代码:
<?php
require_once 'includes/helpers.php';
require 'includes/headerlinks.php';
$fullname = ((isset($_POST['fullname']) && !empty($_POST['fullname']))?sanitize($_POST['fullname']):'');
$phone = ((isset($_POST['phone']) && !empty($_POST['phone']))?sanitize($_POST['phone']):'');
$email = ((isset($_POST['email']) && !empty($_POST['email']))?sanitize($_POST['email']):'');
$message = ((isset($_POST['mmessage']) && !empty($_POST['mmessage']))?sanitize($_POST['mmessage']):'');
$errors = array();
$successes = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
if (isset($_POST['sendMessageButton'])){
$required = array('fullname', 'phone', 'email', 'mmessage');
foreach($required as $field){
if($_POST[$field] === ''){
$errors[] .= 'All fields with an asterisk (*) are required.';
break;
}
}
//Display error or update database
if(!empty($errors)){
//Display Errors
$display = display_errors($errors); ?>
<script>
jQuery('document').ready(function(){
jQuery('#errors').html('<?= $display; ?>');
});
</script>
<?php } else {
$to = "contact@dizasworldbeautycollege.com";
$subject = "Message from DWBC website Send by " . $fullname;
$body = "Name of Sender: " . $fullname . "<br />";
$body .= "Phone Number: " . $phone . "<br />";
$body .= "Email Address: " . $email . "<br />";
$body .= "Message: " . $message;
$headers = "From: " . $email . "/r/n";
$headers .= "Mime-Version: 1.0/r/n";
$headers .= "Content-Type: text/html; charset=utf-8/r/n";
if(mail($to, $subject, $body, $headers)){
$successes[] .= "Your email has been sent. Thank you!";
if(!empty($successes)){
//Display Errors
$display = display_success($successes); ?>
<script>
jQuery('document').ready(function(){
jQuery('#errors').html('<?= $display; ?>');
});
</script>
<?php }
}
else {
$errors[] .= "Sending failed! Please try again.";
if(!empty($errors)){
//Display Errors
$display = display_errors($errors); ?>
<script>
jQuery('document').ready(function(){
jQuery('#errors').html('<?= $display; ?>');
});
</script>
<?php }
}
}
}
}
?>
我尝试将个人电子邮件中的邮件发送到contact@dizasworldbeautycollege.com,该邮件已成功发送和接收。因此,我已经排除了服务器配置。该网站托管在godaddy Linux服务器上。