Page 1 of 1

Newbie Help? Modifying email "from" in PHP

Posted: Sat Nov 21, 2009 1:33 pm
by Feverpitch
Hey Guys and Gals,
I really need some help. I've got this process.php code below working fine for me to send out the form emails. The only problem is whenever a visitor to my site submits a form from my server it places a "Nobody" in the "From" of the emails sent out. This presents a lot of "failed to deliver" issues. I'm hoping one of you brilliant PHPers can tell me how can I change the "Nobody" to something else - my email address or the website address, or what have you. Help? :)

Here is my process.php code:
--------------
<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

mail ("name@website.com," . $_POST['ListRecipients'] . "","" . $_POST['Name'] . " sent this message to you.","" . $_POST['Name'] . " would like to let you know...
");

header("Refresh: 0;url=http://www.website.com");

?>
-------------

Many thanks in advance,
Andy

Re: Newbie Help? Modifying email "from" in PHP

Posted: Sat Nov 21, 2009 2:48 pm
by jackpf
mail() has an argument for headers, such as the from header. Look into that.

http://php.net/mail

Re: Newbie Help? Modifying email "from" in PHP

Posted: Sat Nov 21, 2009 3:32 pm
by Feverpitch
Ah, got it...

...,"FROM: <name@mywebsite.com>")

Thanks a lot. I really appreciate it.

Off and running!

So, if it may help others....

mail ("name@website.com," . $_POST['ListRecipients'] . "","" . $_POST['Name'] . " sent this message to you.","" . $_POST['Name'] . " would like to let you know...
","FROM: <name@mywebsite.com>");

Re: Newbie Help? Modifying email "from" in PHP

Posted: Sun Nov 22, 2009 5:59 am
by jackpf
:)