I'm creating a contact form that emails the company when someone fills out the form. I want it to send an email to the sales team, with a From: header containing the email address of the person that sent it, so they can hit reply on the email and contact the person.
The problem is that the mail() function is returning false if I set any From: header at all.
What am I doing wrong?
Here's my code:
$emailto = "sales@xyz.com";
// does nothing
ini_set('sendmail_from', 'me@abc.com');
$subject = "Test";
$message = "123 Testing";
// This line when included makes mail() fail
$header = "From: {$_REQUEST['name']} <{$_REQUEST['email']}> \r\n"; // fails
$emailsent = mail ($emailto,$subject,$message, $header);
echo $emailsent?'true':'false';