【问题标题】:How to use mail( ) in PHP如何在 PHP 中使用 mail()
【发布时间】:2012-10-01 00:51:06
【问题描述】:

我做错了什么?我只收到“评论:”没有任何实际的正文,还是代码的放置?

第一部分是使用mail()的PHP:

$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; 
mail('a.nurk@gmail.com', 'kjjk', $MESSAGE_BODY, $mailheader) or die ("Failure"); 

第二部分是我的表格:

<form action="javascript:parseResponse();contact-us.php" method="post"      name="ajaxcontactform" id="ajaxcontactform">
    <div class="contacttextarea">
        <input name="contactformid" id="contactformid" type="hidden" value="1" />

        <fieldset>
            <textarea name="comment" id="comment" cols="5" rows="5" class="contacttextarea"onfocus="if (this.value == 'Пожалуйста, оставьте сообщение.') {this.value = '';}">Пожалуйста, оставьте сообщение.</textarea>
        </fieldset>
    </div>

    <div class="contacttextboxes">
        <fieldset>
            <input id="name" name="name" type="text" class="contacttextform" onfocus="if (this.value == 'Ваше имя') {this.value = '';}"value="Ваше имя">
        </fieldset>

        <fieldset>
            <input id="phone" name="phone" type="text" class="contacttextform" onfocus="if (this.value == 'Номер телефона') {this.value = '';}"value="Номер телефона">
        </fieldset>

        <fieldset>
            <input id="email" name="email" type="text" class="contacttextform" onfocus="if (this.value == 'e-mail') {this.value = '';}"value="e-mail">
        </fieldset>

        <fieldset>
            <input name="send" type="submit" class="contactformbutton" value="Send">
        </fieldset>
    </div>
</form>

【问题讨论】:

  • 试试var_dump($_POST),看看你会得到什么。
  • 显示parseResponse();contact-us.php代码。

标签: php forms email


【解决方案1】:

查看http://www.freecontactform.com/email_form.php 以获得完整的邮件脚本。但是您的代码似乎很好。尝试改用$_POST['comment']

【讨论】:

    【解决方案2】:

    尝试取出 nl2br 功能,然后看看它是否有效。老实说,我看不出该脚本有什么问题,我只能假设您的 $_POST['Comment'] 变量始终为空/假。

    【讨论】:

      猜你喜欢
      • 2016-01-06
      • 2014-04-29
      • 1970-01-01
      • 2012-10-23
      • 1970-01-01
      • 2014-03-30
      • 2014-10-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多