dsjbest2015 2014-01-04 06:25
浏览 86

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

Hi I am using the the mail function in php to send emails but the emails in the inbox of the receiver show the name as "unknown sender" in gmail and going in spam in yahoo, here is the code for the function.

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

   mail($to, $sub, $mes, $headers);   
   return mail($to, $sub, $mes, $headers); ;
}
  • 写回答

1条回答 默认 最新

  • douchui1657 2014-01-06 07:36
    关注

    I have solved the problem. The code has now become as under:

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

    I have just added the line

    $headers .= "
    ";
    

    and the email is not longer without the sender's name.

    评论

报告相同问题?