简体   繁体   English

在php上发送邮件时出错

[英]Error on sending mail on php

This is my php code for sending email.But shows Error message"message not send successful.I think the code is working because it shows the error message that i have given.But i can't find out what error is in my code. please help me.Please suggest any way to clear this error. And thank you in advance . 这是我发送电子邮件的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>

';
}

}


?>

Please replace following line: 请替换以下行:

    $headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n"

with this line: 用这一行:

    $headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM