使用PHP发送电子邮件时标题问题

时间:2014-10-20 19:32:13

标签: php email

您好我使用PHP内置的php mail()并使用此函数s =发送电子邮件:

function sendEmail($to,$subject,$message){
   $header = 'From: noreply@xxxxx.com' . "\r\n" .
   'MIME-Version: 1.0' . "\r\n" .
   'Content-type: text/html' . "\r\n" ;
   $retval = mail ($to,$subject,$message,$header);
   if( $retval == true ){
      return true;
   }
   else{
       return false;
   }
}

此功能正在发送电子邮件,但我确实收到的不是来自"来自电子邮件"标题我设置:" noreply@xxxxx.com"但是从我的主机服务器这样:xxx@host205.hostmonster.com

为什么这不能按我的意愿运作?

由于

1 个答案:

答案 0 :(得分:1)

您希望使用格式正确的“From”语句,如下所示:

 $header = 'From: <noreply@xxxxx.com>' . "\r\n" .

 $header = 'From: "no reply" <noreply@xxxxx.com>' . "\r\n" .

另一种可能的方法是:problem with php mail 'From' header

相关问题