duannaikuang1301 2014-01-27 04:53
浏览 289

PHP mailto()表单

I'm working on a contact form currently and it appears to be going through, but I'm not getting the email.I unsure of what the problem is. I'm guessing it's in my PHP, but I don't see where the problem is.

HTML Markup:

<form method="post" id="contact" class="peThemeContactForm" action="mail.php">
    <div id="personal" class="bay form-horizontal">
        <div class="control-group"><!--name field-->
            <div class="controls">
                <input class="required span9" type="text" name="author" data-fieldid="0" value="Full Name" onclick="if(this.value=='Full Name') this.value=''" onblur="if(this.value=='') this.value='Full Name'">
            </div>
        </div>
        <div class="control-group"><!--email field-->
            <div class="controls">
                <input class="required span9" type="email" name="email" data-fieldid="1" value="Your Email" onclick="if(this.value=='Your Email') this.value=''" onblur="if(this.value=='') this.value='Your Email'">
            </div>
        </div>
        <div class="control-group"><!--message field-->
            <div class="controls">
                <textarea name="message" rows="12" class="required span9" data-fieldid="2" onclick="if(this.value=='Type Message') this.value=''" onblur="if(this.value=='') this.value='Type Message'">Type Message</textarea>
            </div>
        </div>
        <div class="control-group">
            <div class="controls send-btn">
                <button type="submit" class="contour-btn red">Send Message</button>
            </div>
        </div>
    </div>
    <div class="notifications">
        <div id="contactFormSent" class="formSent alert alert-success">
            <strong>Your Message Has Been Sent!</strong> Thank you for contacting us.</div> 
        <div id="contactFormError" class="formError alert alert-error">
            <strong>Oops, An error has ocurred!</strong> See the marked fields above to fix the errors.</div>
    </div>
</form>

PHP:

<?php
if(isset($_POST['email'])){
        $mailTo = "jake_ols@live.com";
        $subject = "mail from web";
        $body = "New message from web
<br><br>
FROM: ".$_POST['email']."<br>
NAME: ".$_POST['author']."<br>
COMMENTS: ".$_POST['message']."<br>";   
        $headers = "To: Jake <".$mailTo.">
";
        $headers .= "From: ".$_POST['author']." <".$_POST['email'].">
";
        $headers .= "Content-Type: text/html";
        //envio destinatario
        $mail_success =  mail($mailTo, utf8_decode($subject), utf8_decode($body), $headers);        
}
?>  
  • 写回答

1条回答 默认 最新

  • douxiajia6309 2015-05-03 20:00
    关注

    You most likely answer is that the server does not have mail enabled

    Use phpinfo() to find which ini file you should be editing and make sure that you php server is set up to send mail.

    ; For Win32 only.
    sendmail_from = me@example.com
    

    Alternatively use SMTP and connect to a service like Mailgun https://documentation.mailgun.com/quickstart-sending.html#send-via-smtp

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?