通过邮件功能php发送电子邮件中的未知发件人

时间:2014-01-04 06:25:03

标签: php email

您好我正在使用php中的邮件功能发送电子邮件,但收件人收件箱中的电子邮件在gmail中显示为“未知发件人”,在yahoo中显示垃圾邮件,这是该功能的代码。

function send_email1($from, $fromaddress, $to, $sub, $mes)
{
  $headers = "MIME-Version: 1.0\r\n";  
  $headers .= "Content-type: text/plain; charset=utf-8\r\n";  
  $headers .= "To: ".$to." <".$to.">\r\n";  
  $headers .= "From: ".$from." <".$from.">\r\n";  
  $headers .= "Reply-To: ".$from." <".$from.">\r\n";  
  $headers .= "Return-Path: ".$from." <".$from.">\r\n";  

   mail($to, $sub, $mes, $headers);   
   return mail($to, $sub, $mes, $headers); ;
}

1 个答案:

答案 0 :(得分:1)

我已经解决了这个问题。该代码现已变为:

function send_email1($from, $fromaddress, $to, $sub, $mes)
{
  $headers = "MIME-Version: 1.0\r\n";  
  $headers .= "Content-type: text/plain; charset=utf-8\r\n";  
  $headers .= "To: ".$to." <".$to.">\r\n";  
  $headers .= "From: ".$from." <".$from.">\r\n";  
  $headers .= "Reply-To: ".$from." <".$from.">\r\n";  
  $headers .= "Return-Path: ".$from." <".$from.">\r\n";  
  $headers .= "\r\n";

   mail($to, $sub, $mes, $headers);   
   return mail($to, $sub, $mes, $headers); ;
}

我刚刚添加了一行

$headers .= "\r\n";

如果没有发件人的姓名,电子邮件就不会再存在。