没有收到邮件 [英] Not receiving the mail

查看:72
本文介绍了没有收到邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 PHP邮件功能创建联系表单。我正在通过开发一个免费的虚拟主机提供商来学习这个过程。以下是我的档案:

index.html



 < ;! DOCTYPE html> 
< html>
< head>
< meta charset =utf-8>
< title> HTML5联系人表单< / title>
< link rel =stylesheetmedia =screenhref =styles.css>
< / head>
< body>
< div id =contact>
< form class =contact_formaction =contact.phpmethod =postname =contact_form>
< ul>
< li>
< h2>联络我们< / h2>
< span class =required_notification> *表示必填字段< / span>

< / li>
< li>
< label for =name>名称:< / label>
< input type =textid =namename =nameplaceholder =John Doerequired />
< / li>
< li>
< label for =email>电子邮件:< / label>
< input type =emailname =emailid =emailplaceholder =john_doe@example.comrequired /> < span class =form_hint>正确的格式name@something.com< / span>

< / li>
< li>
< label for =message>消息:< / label>
< textarea name =messageid =messagecols =40rows =6required>< / textarea>
< / li>
< li>
< button class =submitid =submit_btntype =submit>提交表单< / button>
< / li>
< / ul>
< / form>
< / div>
< / body>
< / html>



contact.php



 <?php 
$ field_name = $ _POST ['name'];
$ field_email = $ _POST ['email'];
$ field_message = $ _POST ['message'];
$ mail_to ='babloopuneeth@gmail.com';
$ subject ='来自网站访问者的消息'。$ field_name;
$ body_message ='From:'。$ field_name。\\\
;
$ body_message。='电子邮件:'。$ field_email。\\\
;
$ body_message。='消息:'。$ field_message;
$ headers ='From:'。$ field_email。\r\\\
;
$ headers。='Reply-To:'。$ field_email。\r\\\
;
$ mail_status = mail($ mail_to,$ subject,$ body_message,$ headers);

if($ mail_status){
?>
< script language =javascripttype =text / javascript>
提醒('谢谢您的留言,我们会尽快与您联系。');
window.location ='sample.html';
< / script>
<?php
} else {?>
< script language =javascripttype =text / javascript>
alert('消息失败,请发送电子邮件至gordon@template-help.com');
window.location ='sample.html';
< / script>
<?php
}
?>

我还有一个 styles.css 文件。我收到了一个警告框,内容是感谢您的信息。但我未收到邮件

任何人都可以帮助我吗?我的错在何处? 解决方案

我已经在我的服务器上测试过它,它完美地工作。



如果您使用 000webhost 然后它确实。这是最常见的免费服务,他们不再支持邮件。


I want to create a contact form using PHP mailing function. I am learning the process by developing on a free web hosting provider. Here are my files:

index.html

<!DOCTYPE html>
<html>  
    <head>
        <meta charset="utf-8">
        <title>HTML5 Contact Form</title>
        <link rel="stylesheet" media="screen" href="styles.css">
    </head>     
    <body>
        <div id="contact">
            <form class="contact_form" action="contact.php" method="post" name="contact_form">
                <ul>
                    <li>
                         <h2>Contact Us</h2>
                         <span class="required_notification">* Denotes Required Field</span>

                    </li>
                    <li>
                        <label for="name">Name:</label>
                        <input type="text" id="name" name="name" placeholder="John Doe" required />
                    </li>
                    <li>
                        <label for="email">Email:</label>
                        <input type="email" name="email" id="email" placeholder="john_doe@example.com" required /> <span class="form_hint">Proper format "name@something.com"</span>

                    </li>
                    <li>
                        <label for="message">Message:</label>
                        <textarea name="message" id="message" cols="40" rows="6" required></textarea>
                    </li>
                    <li>
                        <button class="submit" id="submit_btn" type="submit">Submit Form</button>
                    </li>
                </ul>
            </form>
        </div>
    </body>
</html>

contact.php

<?php
    $field_name = $_POST['name'];
    $field_email = $_POST['email'];
    $field_message = $_POST['message'];
    $mail_to = 'babloopuneeth@gmail.com';
    $subject = 'Message from a site visitor '.$field_name;
    $body_message = 'From: '.$field_name."\n";
    $body_message .= 'E-mail: '.$field_email."\n";
    $body_message .= 'Message: '.$field_message;
    $headers = 'From: '.$field_email."\r\n";
    $headers .= 'Reply-To: '.$field_email."\r\n";
    $mail_status = mail($mail_to, $subject, $body_message, $headers);

    if ($mail_status) {
        ?>
        <script language="javascript" type="text/javascript">
            alert('Thank you for the message. We will contact you shortly.');
            window.location = 'sample.html';
        </script>
    <?php
     } else { ?>
        <script language="javascript" type="text/javascript">
            alert('Message failed. Please, send an email to gordon@template-help.com');
            window.location = 'sample.html';
        </script>
    <?php
     } 
?>

I also have a styles.css file. I'm getting the alert box saying Thank you for the message. But I'm not getting a mail.

Can anyone help me? Where am I going wrong?

解决方案

Does your hosting service block port 25? I have tested it on my server and it works perfectly.

If you are using 000webhost then it does. That is the most common free service and they removed support for mail a while back.

这篇关于没有收到邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆