PHP Mail From Name
Posted: Sun Feb 15, 2009 8:42 pm
I'm using this code in a feedback form on a website:
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!
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"; }
?>Thanks!