Page 1 of 1

adding a name to the mail function when sending an email

Posted: Tue Aug 08, 2006 6:44 am
by hame22
Hi

My site offers news stories.

I am attempting to implement a "email a friend this article" feature allowing someone to email the link to a particular news item to a friend.

This works fine

However what I would like the sent email to do is have the users name or email address in the "from" field rather than my postmaster address. I have the users email address and name in variables.

Does anyone know how to achieve this?

Thanks in advance

Posted: Tue Aug 08, 2006 6:55 am
by s.dot
You would set your from header to the senders email address.

Code: Select all

$headers = 'FROM: '.$usersemail."\r\n";

mail($to,$subject,$body,$headers);