在我的项目中,我有以下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", "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;
}
我的问题是,当我用 jesadiyadivyesh@gmail.com 发送邮件时,它会发送邮件到该gmail帐号,但当我发送邮件 vkindustries@yahoo.com 时不发送邮件到该雅虎帐户请帮助我。谢谢。
答案 0 :(得分:-1)
您应该在to
和from
中使用不同的电子邮件我认为这是问题所在。
同样的电子邮件不会工作!!