Forum Moderators: coopster

Message Too Old, No Replies

Email Parameters

         

firefox15

10:33 pm on Feb 21, 2008 (gmt 0)

10+ Year Member



How can I set the name that the email comes from if I am using PHP? I know that I can use the "From" header to set the email address that the email comes from, but I'd like to set the name as well. As an example, this link:

Yahoo! news [m2f.news.yahoo.com]

If you enter your name along with your email address, it will send the email, but it will appear to actually come from a name (whatever name the user types in). Is this possible to do in PHP? Thanks!

[edited by: eelixduppy at 10:52 pm (utc) on Feb. 21, 2008]
[edit reason] fixed link side scroll [/edit]

Receptional Andy

10:37 pm on Feb 21, 2008 (gmt 0)



The PHP manual entry for mail() [php.net] could be friendlier, but you can certainly achieve this in PHP, by setting the headers that all emails use.

As per their example, set a custom header for this information:

$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";

firefox15

10:45 pm on Feb 21, 2008 (gmt 0)

10+ Year Member



Worked great, thanks!

Receptional Andy

10:52 pm on Feb 21, 2008 (gmt 0)



If you're not over familiar with the PHP mail function I would also check the comments in the manual entry above to ensure you aren't making a form vulnerable to exploits. There's a webmasterworld thread on the subject [webmasterworld.com] that may be interesting reading too.