这是我的Send_Mail.php:
<?php
// site owner infos
$email_to = 'kaouach.ahmed@gmail.com';
$success_message = "Your message has been successfully sent.";
$site_name = 'Personal Website';
// contact form fields
$name = trim( $_POST['name'] );
$email = trim( $_POST['email'] );
$message = trim( $_POST['message'] );
$submitted = $_POST['submitted'];
// contact form submitted
if ( isset( $submitted ) )
{
// check for error
if ( $name === '' ){
$name_empty = true;
$error = true;}
elseif ... // Checking of others attributs
// If error
if ( isset( $error ) )
{
echo '<div class="alert alert-error contact-alert"><strong>UNSUCCESS! </strong><ul>';
if ($name_empty) {echo '<li>Required</li>';}
elseif ... // same for Other attribute
else{ echo '<li>An error has occurred while sending your message. Please try again later.</li>';}
echo "</ul></div>";
}
// no error, sending mail
if ( ! isset($error) )
{
$subject = 'Contact form message from your ' . $site_name . ' site';
$body = "Name: $name \n\nEmail: $email \n\nMessage: $message";
$headers = 'From: ' . $name . ' <' . $email . '> ' . "\r\n" . 'Reply-To: ' . $email;
mail( $email_to, $subject, $body, $headers );
echo '<div class="alert alert-success contact-alert"><strong>SUCCESS! </strong>' . $success_message . '</div>';
}
}
?>
当我发送邮件它显示我成功消息并且已发送,但是当我检查我的Gmail邮箱时没有收到任何信息。 那么这里有什么问题以及如何解决它?请
更新2 问题不是从php文件,服务器上不允许匿名邮件发送,所以如何将SMTP,用户名和密码属性添加到我的php文件?
答案 0 :(得分:1)
可能是电子邮件smtp服务器的问题。请确保邮件服务器运行正常。