PHP联系人表格未发送电子邮件。

时间:2018-07-19 20:37:20

标签: php html forms contact

老实说,我找不到代码有什么问题。有人可以帮忙吗?我只希望它将输入内容发送到我的电子邮件中。是的,这是与我的主机关联的电子邮件。

PHP:

<?php

if (isset($_POST['submit'])) { .  

  $name = $_POST['name'];   
  $mailFrom = $_POST['mail'];   
  $message = $_POST['message'];   

  $mailTo = "my@email.com";   
  $headers = "De: " .$mailfrom;   
  $txt = "Você recebeu um email de ".$name.".\n\n".$message;   

  mail($mailTo, $subject, $txt, $headers);
  header("Location: index.php?mailsend");

}

HTML:

        <form id="contact" action="contactform.php" method="post">

            <h3>Deixe a sua mensagem.</h3>

            <input placeholder="Seu Nome" name="name" type="text" tabindex="1" required autofocus oninvalid="this.setCustomValidity('Favor digitar nome válido.')" oninput="setCustomValidity('')">

            <input placeholder="Seu E-Mail" name="mail" type="email" tabindex="2" required oninvalid="this.setCustomValidity('Favor digitar Email válido.')" oninput="setCustomValidity('')">

            <textarea placeholder="Digite sua mensagem aqui..." tabindex="5" name="message" required oninvalid="this.setCustomValidity('Favor digitar mensagem válida.')" oninput="setCustomValidity('')"></textarea>

            <button name="submit" type="submit" id="contact-submit" data-submit="...Sending">ENVIAR</button>

        </form>

是的,很烂,对此感到抱歉。

1 个答案:

答案 0 :(得分:0)

那是什么。?

if (isset($_POST['submit'])) { . <--------

我会尝试删除该期限。除非我的显示器上有斑点。哈哈!

如果这不是问题,则可能是您的smtp设置设置不正确