php mail function to add "nickname"?
Posted: Fri Mar 05, 2010 7:59 am
Hi Guys,
I'm using the php "mail" function to send emails out and wondered if I can set the name when I do this?
To clarify, I can set the email address that it comes from e.g. john.smith@example.com using the header "From:"
but I would like to also set a name e.g. "John Smith" which would show up at the recipent end.
Most of the time when people get emails you see a name like this rather than the email address.
How can I make this happen, I would have thought it would be a header like "Name" or something but can't find anything about it.
My Code:
I'm using the php "mail" function to send emails out and wondered if I can set the name when I do this?
To clarify, I can set the email address that it comes from e.g. john.smith@example.com using the header "From:"
but I would like to also set a name e.g. "John Smith" which would show up at the recipent end.
Most of the time when people get emails you see a name like this rather than the email address.
How can I make this happen, I would have thought it would be a header like "Name" or something but can't find anything about it.
My Code:
Code: Select all
$to= "customer@somewhere.com";
$message = "Hello, how are things?";
$subject = "Example Subject";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: john.smith@example.com\r\n";
mail($to, $subject, $message, $headers);