2016-05-14 133 views
0

在我的項目中,我有以下的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 ="[email protected]"; //"[email protected]"; 

//from email adress 
$emailFrom ="[email protected]"; //"[email protected]"; 

//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-][email protected]([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; 
} 

我的問題是,當我發送郵件[email protected]將郵件發送到Gmail的戶頭,但是當我用[email protected]它不發送郵件發送郵件到雅虎帳戶請幫助我。謝謝。

+0

你檢查了垃圾郵件文件夾嗎? –

+0

是的,我檢查。 –

+0

我遇到同樣的問題。電子郵件實際上在其他平臺上通過。 – Kama

回答

-1

你應該使用不同的電子郵件tofrom我認爲這是問題所在。 相同的電子郵件不會工作!

相關問題