PHP的本地主机邮件没有收到

时间:2018-07-08 16:51:55

标签: php html contact-form

我想做一个“联系我”页面。我没有收到用于测试的电子邮件,因此出现了问题。首先,我使用以下命令从终端使用本地主机:

php -S 127.0.0.1:8080

当我访问localhost:8080时,网站运行正常,但没有收到与我联系的任何电子邮件。这是我的HTML和php

HTML:

      <form class="contact-form" action="contactform.php" method="post">
        <input type="text" name="name" class="form-control" placeholder="Name" required><br>
        <input type="email" name="email" class="form-control" placeholder="Email" required><br>
        <textarea name="message" class="form-control" rows="4" placeholder="Message" required></textarea><br>
        <button type="submit" name="submit" class="form-control submit">SEND MESSAGE</button>
      </form>

PHP:

<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$mailFrom = $_POST['email'];
$msg = $_POST['message'];

$mailTo = "monbay@inboxbear.com";
$subject = "Form Submission from ".$name;

mail($mailTo, $subject, $msg);
echo '<p>Your message has been sent!</p>';
}
?>

0 个答案:

没有答案