未收到Php电子邮件

时间:2014-06-23 17:09:51

标签: php html forms email

我使用基本的php邮件功能发送电子邮件。但由于未知的原因,没有收到。我无法找到代码的任何问题。有帮助吗?提前谢谢。

Website Link

PHP

<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
  ?>
      <?php
} else {    // the user has submitted the form
  // Check if the "from" input field is filled out
  if (isset($_POST["contact_email"])) {
    $from = $_POST["contact_email"]; // sender
    $subject = $_POST["contact_name"];
    $message = $_POST["contact_message"];
    // message lines should not exceed 70 characters (PHP rule), so wrap it
    $message = wordwrap($message, 70);
    // send mail
    mail("email@example.com",$subject,$message,"From: $from\n");
    echo "Thank you for sending us feedback";
  }
}
?>

FORM

<form id="contactForm" class="cmxform" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" >
        <strong>Usa il modulo sottostante per inviarci un messaggio email:</strong>
        <div>
          <label for="contact_name">Nome </label>
          <em>(obbligatorio, almeno 2 lettere)</em><br />
          <input id="contact_name" name="contact_name" size="30" class="required" minlength="2" value="" required="required" />
        </div>
        <div>
          <label for="contact_email">E-Mail </label>
          <em>(obbligatorio)</em><br />
          <input id="contact_email" name="contact_email" size="30" type="email"  class="required email" value="" />
        </div>
        <div>
          <label for="contact_phone">Telefono </label>
          <em>(opzionale)</em><br />
          <input id="contact_phone" name="contact_phone" size="14" type="number" class="phone" value="" maxlength="14" />
          <label for="contact_ext">interno </label>
          <input id="contact_ext" name="contact_ext" size="5" type="tel" class="ext" value="" maxlength="5" />
        </div>
        <div>
          <label for="contact_message">Il tuo commento </label>
          <em>(obbligatorio)</em><br />
          <textarea id="contact_message" name="contact_message" cols="70" rows="7" class="required"></textarea>
        </div>

        <div>
          <input name="submit" class="submit" type="submit" value="Invia"/>
        </div>

      </form>

1 个答案:

答案 0 :(得分:1)

PHP Mail返回布尔值。如果邮件是由邮件发送的,则为真,否则为false。 (这并不意味着邮件已被收到,仅被发送)。 尝试:

var_dump(mail("email@example.com",$subject,$message,"From: $from\n"));