這是我的郵件功能php
,但它不能正常工作。 請幫我解決我的問題。php郵件功能在if條件下不工作
<?php
if($_POST && array_key_exists('submit_contact',$_POST)){
$to = "[email protected]";
$subject="Contact Form";
$fname =$_POST['fname'];
$email=$_POST['email'];
$telno=$_POST['telno'];
$mess=$_POST['your-message'];
$body = "<html><body><div>";
$body .= "<h1><b><u>Contact Form Details</u></b></h1>";
$body .= "<h3>Full Name:\t". $fname."</h3>";
$body .= "<h3>E-mail:\t". $email."</h3>";
$body .= "<h3>Telephone:\t". $telno."</h3>";
$body .= "<h3>Message:</h3>\t<p>". $mess."</p>";
$body .= "</div></body></html>";
$headers = "From:". $email. "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "Reply-To:".$email."\r\n"."Return-Path:". $email . "\r\n". "X-Mailer: PHP/" . phpversion();
$subjectr="Confirmation Notice";
$messages="<html><body>";
$messages .="<div style=''><a href='index.html'><img src='http://example.com/images/logo.png' alt='logo'/></a></div>";
$messages .="<table style=''width='600px'><tr><td bgcolor='black'height='30px'><font style='padding-left:10px;color:#d8b53e;font-size:20px;'>Reference # 786733</font></td> </tr>";
$messages .="<td><br/>Dear Concerned,<br/>Thank you for considering</td></tr>";
$messages .="<tr><td>© 2014</td></tr></table>";
$messages .="</body></html>";
$headerss = "From:".$to. "\r\n";
$headerss .= "MIME-Version: 1.0" . "\r\n";
$headerss .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headerss .= "Reply-To:".$to."\r\n"."Return-Path:".$to. "\r\n". "X-Mailer: PHP/" . phpversion();
if(mail($to,$subject,$body,$headers)){
mail($email,$subjectr,$messages,$headerss);
echo "<script> window.alert('E-mail successfully Sent!');</script>";
}
else{
echo "<script> window.alert('Error Try Again Please');</script>";
}
}
?>
http://stackoverflow.com/questions/how-to-ask – Rufinus
plz提供你的完整代碼 –
是因爲你有兩個'$ headerss'嗎?也許打開error_reporting,應該很容易排除故障..或在'$ subjectr' – Ben