这是我的发送电子邮件的PHP代码。但是显示错误消息“消息未发送成功。我认为代码正常工作,因为它显示了我给出的错误消息。但我无法找出错误是什么我的代码。请帮助我。请建议任何方法来清除此错误。 并提前感谢你。
if (!empty($_POST['nume']) || !empty($_POST['email']) ) {
$email_to = "indeetvous@bbox.fr";
$email_subject = "Contact Form Indeetvous:";
$first_name = $_POST['nume']; // required
$last_name = $_POST['companie']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['mesaj']; // required
$email_message ="";
$email_message .= "First Name: ".($first_name)."\n";
$email_message .= "Last Name: ".($last_name)."\n";
$email_message .= "Email: ".($email_from)."\n";
$email_message .= "Comments: ".nl2br($comments)."\n";
$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion();
if (mail($email_to, $email_subject, $email_message, $headers)) {
echo ' <div id="contact_div">
Message Sent Successfully. Thank You for your interest in us.
</div>
<div id="contact_info">
<ul>
<li>
3, Allée de l\'Erdre
</li>
<li>44000 Nantes</li>
<li><a class="link"
href="mailto:indeetvous@bbox.fr">indeetvous@bbox.fr</a></li>
<li>Téléphone : 02 40 48 73 91</li>
</ul>
<a href="#locatie" id="contact_link">SEE LOCATION</a>
</div>
';
} else {
echo ' <div id="contact_div">
Message Sending Failed. Try Again Later.
</div>
<div id="contact_info">
<ul>
<li>3, Allée de l\'Erdre </li>
<li>44000 Nantes</li>
<li><a class="link"
href="mailto:indeetvous@bbox.fr">indeetvous@bbox.fr</a></li>
<li>Téléphone : 02 40 48 73 91</li>
</ul>
<a href="#locatie" id="contact_link">SEE LOCATION</a>
</div>
';
}
}
?>
答案 0 :(得分:1)
请更换以下内容:
$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n"
这一行:
$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n";