Page 1 of 1

PHP Mail From Name

Posted: Sun Feb 15, 2009 8:42 pm
by aalbright
I'm using this code in a feedback form on a website:

Code: Select all

<?php
$to = "you@yoursite.com";
$subject = "Contact Us";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>
Is it possible to add a from name to the email that is sent? The from name on the email would be "Contact form" or something, instead of the email the email address given. This would help to identify emails as ones from the contact form.

Thanks!

Re: PHP Mail From Name

Posted: Sun Feb 15, 2009 9:04 pm
by sparrrow

Code: Select all

$from = "John Smith <john.smith@devnetwork.net>";