在这段代码中我无法打印echo语句如何能够知道此代码是否正在发送邮件。我是网页设计师而不是开发人员。如果echo语句正常工作意味着我可以理解代码是否正常工作
if(isset($_REQUEST['email']))
{
echo "dfsdkf";
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "info@ltnts.com";
$email_subject = "Enquiry Details From ltnt.in";
$customer_name=$_REQUEST['fullname'];
$organisation=$_REQUEST['cmp_name'];
$phone_num=$_REQUEST['contact'];
$email=$_REQUEST['logo_emailid'];
$country=$_REQUEST['country'];
$state=$_REQUEST['state'];
$city=$_REQUEST['logo_city'];
$zipcode=$_REQUEST['logo_zipcode'];
$project_type=$_REQUEST['market_type'];
$website_url=$_REQUEST['logo_name'];
$website_purpose=$_REQUEST['business_desc'];
$website_keyword=$_REQUEST['web_keyword'];
$Competitors=$_REQUEST['targent_aud'];
$sample_websites=$_REQUEST['targent_aud1'];
$no_of_updation=$_REQUEST['updation'];
$required_pages=$_REQUEST['checkbox'];
$additional_page=$_REQUEST['addition_page'];
$other_details=$_REQUEST['other_d'];
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Customer Name: ".clean_string($customer_name)."\n";
$email_message .= "organisation: ".clean_string($organisation)."\n";
$email_message .= "phone_num: ".clean_string($phone_num)."\n";
$email_message .= "Email ID: ".clean_string($email)."\n";
$email_message .= "Country: ".clean_string($country)."\n";
$email_message .= "state: ".clean_string($state)."\n";
$email_message .= "city: ".clean_string($city)."\n";
$email_message .= "zipcode: ".clean_string($zipcode)."\n";
$email_message .= "project_type: ".clean_string($project_type)."\n";
$email_message .= "website_url: ".clean_string($website_url)."\n";
$email_message .= "website_purpose: ".clean_string($website_purpose)."\n";
$email_message .= "website_keyword ID: ".clean_string($website_keyword)."\n";
$email_message .= "Competitors: ".clean_string($Competitors)."\n";
$email_message .= "sample_websites: ".clean_string($sample_websites)."\n";
$email_message .= "no_of_updation: ".clean_string($no_of_updation)."\n";
//$email_message .= "required_pages: ".clean_string($required_pages)."\n";
$email_message .= "additional_page: ".clean_string($additional_page)."\n";
$email_message .= "other_details: ".clean_string($other_details)."\n";
$newsletter = $_POST['checkbox'];
if ($newsletter != 'Yes')
{
$newsletter = 'No';
}
$email_message .="Selected:".clean_string($newsletter)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email_to."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}
else
{
echo "dfjdhfjshfjz";
}
?>
<input name="checkbox[] "type="checkbox" name="page_Home" value="Home" id="pageHome" onChange="toggleVisibility('home');" /><label for="pageHome"> Home</label><img id="home" src="images/icon-tick.png" style="visibility:hidden"/><br/>
<input name="checkbox[]" value="About_us" id="page_Aboutus" type="checkbox" onChange="toggleVisibility('aboutus');"><label for="page_Aboutus"> About Us</label><img id="aboutus" src="images/icon-tick.png" style="visibility:hidden" /><br/>
<input name="checkbox[]" value="Services" id="pageServices" type="checkbox" onChange="toggleVisibility('services');"><label for="pageServices"> Services</label><img id="services" src="images/icon-tick.png" style="visibility:hidden" /><br/>
<input name="checkbox[]" value="Products" id="pageProducts" type="checkbox" onChange="toggleVisibility('products');"><label for="pageProducts"> Products</label><img id="products" src="images/icon-tick.png" style="visibility:hidden"/><br/>
<input name="checkbox[]" value="Enquiry" id="pageEnquiry" type="checkbox" onChange="toggleVisibility('enquiry');"><label for="pageEnquiry"> Enquiry</label><img id="enquiry" src="images/icon-tick.png" style="visibility:hidden"/><br/>
<input name="checkbox[]" value="Contact_us" id="pageContact" type="checkbox" onChange="toggleVisibility('Contact');"><label for="pageContact">Contact Us</label><img id="Contact" src="images/icon-tick.png" style="visibility:hidden" /><br/>
答案 0 :(得分:0)
首先检查是否设置了$_REQUEST['email']
,以便知道代码是否正在发送邮件
当error_get_last()
返回false时,您可以使用mail()
。
使用print_r(error_get_last())可以得到正确的错误
如果邮件成功接受传递,则mail()返回TRUE,否则返回FALSE。
重要的是要注意,仅仅因为邮件被接受传递,并不意味着邮件将到达目的地。
使用@mail抑制警告
使用
if( @mail($email_to, $email_subject, $email_message, $headers) ) {
echo 'mail send';
} else {
print_r(error_get_last());
}