如何使用PHP在空格中显示带有空格的名称?

问题描述:

I am currently sending text email in PHP and doing something like this:

$from = "from: Hike Attendance Update@comehike.com";
$to_email_address = 'some email';
$subject = 'Some subject';
$contents = 'Blah';

mail($to_email_address, $subject, $contents, $from);

When I send it, it appears as sent from Hike.Attendance.Update which doesn't look very good. How can I make it appear with spaces instead of dots?

Thanks, Alex

我目前正在用PHP发送文本电子邮件并执行以下操作: p>

  $ from =“from:Hike Attendance Update@comehike.com”; 
 $ to_email_address ='some email'; 
 $ subject ='some subject'; 
 $ contents ='Blah'; 
  
 
($ to_email_address,$ subject,$ contents,$ from); 
  code>  pre> 
 
 

当我发送它时,它显示为从Hike.Attendance.Update发送的 看起来很不错。 如何使用空格而不是点来显示? p>

谢谢, Alex p> div>

Try:

$from = "from: \"Hike Attendance\" <Update@comehike.com>";

I think that's specified in some RFC for email, namely RFC 5322.

When specifying the actual name, put the email address in <> chars:

$from = "from: Hike Attendance <Update@comehike.com>";