php sendmail标头无法正常工作

I have the following headers in my Mailer class

// domain is equal to current domain with capital letters if any
$from = domain;
$replyto = 'noreply@'.strtolower(domain);

$headers = "From: $from
Reply-To: ".$replyto;
$headers .= "
MIME-Version: 1.0
Content-Type: text/html; charset=\"utf-8\"
";

But for some reason when I send an email in my mailbox I receive an e-mail from myusername@myhost.com which is terrible. How can I have just my site name as the sender?

In order to parse names and email-addresses correctly, you should provide them in the following format:

'From: Name <email@domain.tld>'

So that would be something like

'From: Marty McVry <marty.mcvry@mydomain.com>'

Using your example:

$headers = "From: $from <$replyto>
Reply-To: ".$replyto;

Just a reminder: I hope that you don't have to use $domain instead of domain... Would be a silly typo otherwise. :-)

You could try using this code:

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "
" .
'Reply-To: webmaster@example.com' . "
" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

For more information, read about the mail function