邮件不发送雅虎

时间:2016-05-14 11:49:49

标签: php html email

在我的项目中,我有以下html。

<form id="contact-form" action="php/mail.php">
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="text" id="cname" name="cname" placeholder="* Company Name..." />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="text" id="name" name="name" placeholder="* Contact Person..." />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <textarea class="span12" name="address" id="address" placeholder="* Address..."></textarea>                      </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="text" id="mobile" name="mobile" placeholder="* Mobile No..." />
                                        <div class="error left-align" id="err-mobile">Please enter Valid Mobile No.</div>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="text" id="country" name="country" placeholder="* Country..." />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="text" id="city" name="city" placeholder="* City..." />                                        </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="text" id="telephone" name="telephone" placeholder="* Telephone..." />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="email" name="email" id="email" placeholder="* Email..." />
                                        <div class="error left-align" id="err-email">Please enter valid email adress.</div>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <input class="span12" type="text" id="web" name="web" placeholder="* Website..." />                                        </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <textarea class="span12" name="message" id="message" placeholder="* Message..."></textarea>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <div class="controls">
                                        <button id="send-mail" class="message-btn">Send message</button>
                                    </div>
                                </div>
                            </form>

我的php / mail.php文件是。

<?php

include 'functions.php';

if (!empty($_POST)){

$data['success'] = true;
$_POST  = multiDimensionalArrayMap('cleanEvilTags', $_POST);
$_POST  = multiDimensionalArrayMap('cleanData', $_POST);

//your email adress 
$emailTo ="vkindustries@yahoo.com"; //"yourmail@yoursite.com";

//from email adress
$emailFrom ="vkindustries@yahoo.com"; //"contact@yoursite.com";

//email subject
$emailSubject = "Mail from WEBSITE";

 $cname = $_POST["cname"];
 $name = $_POST["name"];
 $address = $_POST["address"];
 $mobile = $_POST["mobile"];
 $country = $_POST["country"];
 $city = $_POST["city"];
 $telephone = $_POST["telephone"];
 $email = $_POST["email"];
 $web = $_POST["web"];
 $message = $_POST["message"];
 if($mobile == "")
 $data['success'] = false;

 if (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) 
  $data['success'] = false;

 if($data['success'] == true){

  $message = "COMPANY NAME: $cname<br>
  NAME: $name<br>
 ADDRESS: $address<br>
 MOBILE NO: $mobile<br>
 COUNTRY: $country<br>
 CITY: $city<br>
  TELEPHONE: $telephone<br>
 EMAIL: $email<br>
 WEBSITE: $web<br>
 MESSAGE: $message";


 $headers = "MIME-Version: 1.0" . "\r\n"; 
 $headers .= "Content-type:text/html; charset=utf-8" . "\r\n"; 
 $headers .= "From: <$emailFrom>" . "\r\n";
 mail($emailTo, $emailSubject, $message, $headers);

 $data['success'] = true;
 echo json_encode($data);
 }
 }

我的php / functions.php文件是。

<?php

// Strips nasty tags from code..
function cleanEvilTags($data) {
$data = preg_replace("/javascript/i", "j&#097;v&#097;script",$data);
$data = preg_replace("/alert/i", "&#097;lert",$data);
$data = preg_replace("/about:/i", "&#097;bout:",$data);
$data = preg_replace("/onmouseover/i", "&#111;nmouseover",$data);
$data = preg_replace("/onclick/i", "&#111;nclick",$data);
$data = preg_replace("/onload/i", "&#111;nload",$data);
$data = preg_replace("/onsubmit/i", "&#111;nsubmit",$data);
 $data = preg_replace("/<body/i", "&lt;body",$data);
$data = preg_replace("/<html/i", "&lt;html",$data);
$data = preg_replace("/document\./i", "&#100;ocument.",$data);
$data = preg_replace("/<script/i", "&lt;&#115;cript",$data);
return strip_tags(trim($data));
}

// Cleans output data..
function cleanData($data) {
$data = str_replace(' & ', ' &amp; ', $data);
return (get_magic_quotes_gpc() ? stripslashes($data) : $data);
}

function multiDimensionalArrayMap($func,$arr) {
$newArr = array();
if (!empty($arr)) {
foreach($arr AS $key => $value) {
  $newArr[$key] = (is_array($value) ? multiDimensionalArrayMap($func,$value) : $func($value));
}
}
return $newArr;
}

我的问题是,当我用 jesadiyadivyesh@gmail.com 发送邮件时,它会发送邮件到该gmail帐号,但当我发送邮件 vkindustries@yahoo.com 时不发送邮件到该雅虎帐户请帮助我。谢谢。

1 个答案:

答案 0 :(得分:-1)

您应该在tofrom中使用不同的电子邮件我认为这是问题所在。 同样的电子邮件不会工作!!