Newbie Help? Modifying email "from" in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Feverpitch
Forum Newbie
Posts: 2
Joined: Sat Nov 21, 2009 1:25 pm

Newbie Help? Modifying email "from" in PHP

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post by jackpf »

mail() has an argument for headers, such as the from header. Look into that.

http://php.net/mail
Feverpitch
Forum Newbie
Posts: 2
Joined: Sat Nov 21, 2009 1:25 pm

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

Post 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>");
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post by jackpf »

:)
Post Reply