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", "javascript",$data);
$data = preg_replace("/alert/i", "alert",$data);
$data = preg_replace("/about:/i", "about:",$data);
$data = preg_replace("/onmouseover/i", "onmouseover",$data);
$data = preg_replace("/onclick/i", "onclick",$data);
$data = preg_replace("/onload/i", "onload",$data);
$data = preg_replace("/onsubmit/i", "onsubmit",$data);
$data = preg_replace("/<body/i", "<body",$data);
$data = preg_replace("/<html/i", "<html",$data);
$data = preg_replace("/document\./i", "document.",$data);
$data = preg_replace("/<script/i", "<script",$data);
return strip_tags(trim($data));
}
// Cleans output data..
function cleanData($data) {
$data = str_replace(' & ', ' & ', $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]它不發送郵件發送郵件到雅虎帳戶請幫助我。謝謝。
你檢查了垃圾郵件文件夾嗎? –
是的,我檢查。 –
我遇到同樣的問題。電子郵件實際上在其他平臺上通過。 – Kama