Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP表单只提交来自Gmail的电子邮件,没有其他地址_Php_Html - Fatal编程技术网

PHP表单只提交来自Gmail的电子邮件,没有其他地址

PHP表单只提交来自Gmail的电子邮件,没有其他地址,php,html,Php,Html,我有一个html从。当用户提交表单时,我正在使用php向给定的电子邮件地址发送电子邮件。发送到gmail账户的电子邮件处理得非常好。然而,发送给雅虎、美国在线等提供商的邮件无法通过。我的代码中没有过滤机制来过滤电子邮件地址。一些发送到雅虎邮箱地址的邮件很少通过。但aol根本不去。这里的问题是什么 我的html代码: <section class="contact-container"> <div class="container mtb">

我有一个html从。当用户提交表单时,我正在使用php向给定的电子邮件地址发送电子邮件。发送到gmail账户的电子邮件处理得非常好。然而,发送给雅虎、美国在线等提供商的邮件无法通过。我的代码中没有过滤机制来过滤电子邮件地址。一些发送到雅虎邮箱地址的邮件很少通过。但aol根本不去。这里的问题是什么

我的html代码:

<section class="contact-container">
            <div class="container mtb">
                <div class="row">
                    <div class="col-md-8 wow fadeInLeft">
                        <h4>Get in touch</h4>
                        <hr>
                            <p>Leave a comment, review, or general musings.
    </p><br/>

    <form method="post" id="captcha_form" name=
    "captcha_form" action="mailform.php"><fieldset><ol>


    </li><li><label class="solo" for="email">Email address:</label>
    <span class="required">(required)</span><input type="text" class="solo 
    input" name="email" id="email" value="" />

    </li><li><label class="solo" for="name">Name:</label><input type=
    "text" class="solo input" name="name" id="name" value="" />



    </li><li><label class="solo" for="subject">Subject:</label>
    <span class="required">(required)</span> <input type="text" class=
    "solo input" name="subject" id="subject" />

    </li><li><label class="solo" for="message">Message:</label>
    <span class="required">(required)</span>
    <div class="solo input"><textarea class="solo input" name="message" id=
    "message" ></textarea><br />

    <p><input name="submit" id="submit" type="submit" value="Send" style=
    "float:  right;" /></p></div>
    </li></ol>
    </fieldset></form> &nbsp;<br />&nbsp;<br />&nbsp;

</div>

联系

留下评论、评论或一般性思考。


  • 电子邮件地址: (必选)
  • 姓名:
  • 主题: (必选)
  • 信息: (必选)



  • 下面是mailform.php的片段:

     <?php 
        $dontsendemail = 0;
        $possiblespam = FALSE;
        $strlenmessage = "";
        $email = $_REQUEST['email']; 
        $message = $_REQUEST['message']; 
        $subject = $_REQUEST['subject']; 
        $emailaddress = "email@gmail.com";
    
        / Check human test input box
        if(isset($_REQUEST["htest"]) && $_REQUEST["htest"] != "") die
        ("Possible spam     detected. Please hit your browser back button 
        and check your entries."); 
        // Check email address function
        function checkemail($field) {
        // checks proper syntax
        if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+
        ([a-zA-Z0-  9._-]+)+$/", $field))
        {
            die("Improper email address detected. Please hit your browser back 
        button and enter a proper email address."); 
            return 1;
        }
        }
    
        // Spamcheck function
        function spamcheck($field) {
        if(preg_match("/to:/i",$field) || preg_match("/cc:/i",$field) 
        ||   preg_match("/\r/i",$field) || preg_match("/i\n/i",$field) 
        ||    preg_match("/%0A/i",$field)){ 
            $possiblespam = TRUE;
        }else $possiblespam = FALSE;
        if ($possiblespam) {
            die("Possible spam attempt detected. If this is not the case, please 
        editthe content of the contact form and try again.");
            return 1;
        }
        }
    
        if ($dontsendemail == 0) {
        $message="";
        $message.="Name: ".$name."\r\n";
        $message.="Mailing Address: \r\nLine 1: ".$addressline1."\r\nLine 
        2: ".$addressline2."\r\nCity: ".$city."\r\nState: ".$state."
        \r\nZip:  ".$zip."\r\n";
        $message=$message."\r\nMessage:\r\n".$_REQUEST['message'];
        mail($emailaddress,"$subject",$message,"From: $email" ); 
        include "email_sent.php";
        echo "Thank you, I will respond shortly.";
    }
    

    不要使用正则表达式来确认电子邮件地址。真正的正则表达式就像一整天。使用或。你会注意到它们比基本正则表达式复杂得多。电子邮件规范是疯狂的:

    更具体地说,
    如果(!filter\u var($field,filter\u VALIDATE\u email))死亡(…)。见()。需要5.2,但您至少应该使用该选项。谢谢您的帮助。:)我不太明白你的意思。我对php相当陌生,并且复制和粘贴了很多代码。我将不得不问你更多的规格,我将采取从这些网站。感谢您的理解。关于电子邮件地址验证,请参阅下面Charles的评论。此外,如果您在电子邮件和主题字段中测试换行符(
    /[\r\n]/
    ),您应该能够避开需要从新行开始的标题插入。正确验证电子邮件地址也可以避免标头插入,因为不允许使用换行符和逗号。