简体   繁体   English

PHP mailto()表单

[英]PHP mailto() form

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. 我猜它在我的PHP中,但我没有看到问题出在哪里。

HTML Markup: HTML标记:

<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:

<?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.">\r\n";
        $headers .= "From: ".$_POST['author']." <".$_POST['email'].">\r\n";
        $headers .= "Content-Type: text/html";
        //envio destinatario
        $mail_success =  mail($mailTo, utf8_decode($subject), utf8_decode($body), $headers);        
}
?>  

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. 使用phpinfo()查找您应该编辑哪个ini文件,并确保您已将php服务器设置为发送邮件。

; 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 或者使用SMTP并连接到Mailgun等服务https://documentation.mailgun.com/quickstart-sending.html#send-via-smtp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM