我有一个简单的网站,托管在 www.000webhost.com 上。问题是我在我网站的联系表单中使用了简单的 php mail 功能来发送邮件。它显示邮件已发送,但实际上我没有收到该电子邮件地址上的邮件。这是所有文件的代码......
contact.php
<?php
include 'config.php';
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post)
{
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);
$error = '';
if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
"From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail)
{
echo 'OK';
}
}
}
?>
的config.php
<?php
// To
define("WEBMASTER_EMAIL", 'mymail@mail.com');
?>
和index.html
<form action="contact/contact.php" method="post" role="form" class="contactForm">
<div class="form-group">
<label for="name">Your Name</label>
<input type="text" name="name" class="form-control" id="name" placeholder="Your Name" data-rule="maxlen:4" data-msg="Please enter at least 4 chars" />
<div class="validation"></div>
</div>
<div class="form-group">
<label for="email">Your Email</label>
<input type="email" class="form-control" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" />
<div class="validation"></div>
</div>
<div class="form-group">
<label for="subject">Subject</label>
<input type="text" class="form-control" name="subject" id="subject" placeholder="Subject" data-rule="maxlen:4" data-msg="Please enter at least 8 chars of subject" />
<div class="validation"></div>
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us"></textarea>
<div class="validation"></div>
</div>
<button type="submit" class="btn btn-theme pull-left">SEND MESSAGE</button>
</form>
打印回信表示邮件已发送,但当我查看我的帐户时,我没有收到。