使用php从web表单发送电子邮件

使用php从web表单发送电子邮件,php,html,email,Php,Html,Email,我编写了一个php脚本,在单击按钮时从web表单发送电子邮件。邮件正在工作,但它在收件箱中显示此警告消息:“此邮件可能不是从example@example.com". 以下是我的php代码: 谢谢,您的邮件已发送。我们将很快与您联系。 有没有办法消除这个令人不安的信息? 谢谢你下面的代码它会工作的试试这个 <?php $contact_name=$_POST['contact_name']; $contact_email=$_POST['contact_email']; $contac

我编写了一个php脚本,在单击按钮时从web表单发送电子邮件。邮件正在工作,但它在收件箱中显示此警告消息:“此邮件可能不是从example@example.com". 以下是我的php代码:


谢谢,您的邮件已发送。我们将很快与您联系。
有没有办法消除这个令人不安的信息?
谢谢你

下面的代码它会工作的试试这个

<?php
$contact_name=$_POST['contact_name'];
$contact_email=$_POST['contact_email'];
$contact_phone=$_POST['contact_phone'];
$contact_message=$_POST['contact_message'];
$to_email = 'xxx@domain.com'; //you can give email id to whom you need to send
$html = 'your custom body of the mail';
$subject = 'you subject' . $contact_message;
$message = $html;
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ABC' . "\r\n"; //DONT GIVE SPACE IN "ABC"  //you can replace your value but no space.. if u give space you can get email in spam only..
$response = mail($to_email,$subject,$message,$headers);
if($response)
{
    echo "Mail sent";
}
else
{
    echo "Not sent.. Try later";
}
?>


如果您的电子邮件正在发送给发件人,那么为什么不使用
错误报告(0)
?@SulthanAllaudeen
error\u reporting()
是一个PHP函数。警告消息出现在收件人收件箱中的消息中,其中没有涉及PHP。很抱歉,我以为触发电子邮件时会抛出此错误。谢谢:)@Indra:你在
$\u POST['email']
中的发件人地址是什么,因为有些服务器也会处理这个问题。尝试使用真正的电子邮件address@SulthanAllaudeen我在$_POST['email]中使用了真实的电子邮件地址。