我正在创建php页面并创建发布到php脚本的按钮。在我的脚本中,我创建了普通邮件功能所需的内容。我传递了所有变量,它成功发送了。但我的Gmail没有收到任何邮件。
sendmail.php
<?php
$to = 'mygmail@gmail.com';
$subject = 'Message from my page';
$headers = "To: email@hotmail.com\n" .
"From: From Address <from@mydomain.com>\n" .
"MIME-Version: 1.0\n" .
"Content-Type: text/html; charset=iso-8859-1";
$message = 'TheMessage Body';
mail( $to, $subject, $message, $headers );
$result = mail($to, $subject, $message, $headers);
if($result) {
echo "MAIL SENT";
}else {
echo 'MAIL NOT SENT';
}
?>
HTML
<form action="sendmail.php" method="POST" enctype="text/plain" id="contactForm">
<div class="col-sm-12">
<!-- if mail sent successfully -->
<h4 class="success">
<i class="fa fa-check"></i> Your message has been sent successfully.
</h4>
<!-- if mail sent unsuccessfully -->
<h4 class="error">
<i class="fa fa-warning"></i> E-mail must be valid and message must be longer than 1 character.
</h4>
</div>
<div class="col-sm-6">
<input id="name" type="text" name="name" placeholder="Your Name">
</div><!-- col-sm-6 end -->
<div class="col-sm-6">
<input id="email" type="email" name="email" placeholder="Your Email">
</div><!-- col-sm-6 end -->
<div class="col-md-12">
<textarea type="text" name="messages" class="textarea-box" id="message" rows="5" placeholder="Message"></textarea>
<button class="btn-new btn-bold" type="submit" id="submit" name="submit">Submit Message</button>
</div>
</form>
答案 0 :(得分:0)
您正在使用的电子邮件&#34;来自:&#34;必须存在于您的服务器中。 还有一点,您是否曾尝试向其发送非Gmail电子邮件帐户 - 它是否已到达?