Forum Moderators: coopster
I am less than a newbie when it comes to PHP. I recently picked up a book and I am trying to get through. So please keep that in mind when you post a reply.
I have a mail form that is working great except that when it sends me the e-mails, it does not want to put the sender's e-mail address in the "From" field of the e-mail. The book that I have simply says that there is not a foolproof way to fix this. I say, that is why I bought the book, but it still doesn't explain it.
If you know a workaround for this little issue I would appreciate your help. I tried searching this site for a similar post, but I am must not be typing the right question, 'cause I ain't finding an answer.
Thanks in advance for you help.
-LG
ini_set("sendmail_from", "replyadress@domain.com");
Set this in your formmail script near the top.
from: [be2.php.net...]
Congrats on springing for the php book; this helps alot in getting the programming stuff into your head (and a lot of newbies don't do this). Hope it's a relatively new one. Still, make a habit of checking out the manual over at php.net. Get the firefox browser, and in the right-hand searchbox on top, if there isn't a drop-down option for 'add engines', then look for an extension called 'mycroft' and add the php functions lookup option. Just type in a function name, and bang, you're there. Users' comments are really helpful too. This is the best way to learn how to use the functions well; having the paper book will help too, since you can go over real life examples in a more restful environment.
And welcome to webmasterworld.
<?
mail('info@MYDOMAIN.com', $_POST['subject'], $_POST['body'], $_POST['emailAddress']);
?>
If someone could give the exact way to correct the problem, I would appreciate it.
mail('info@MYDOMAIN.com', $_POST['subject'], $_POST['body'], "From: " .$_POST['emailAddress']);
Typically I've done it with the name as well
mail('info@MYDOMAIN.com', $_POST['subject'], $_POST['body'], "From: " . $_POST['first_name'] . " " . $POST['last_name'] . " <" . $_POST['emailAddress'] . ">");
The book might be talking about the Return-Path part of the header which I haven't figured out how to override on a shared server. The php mails I send still have the notorious 'nobody' as the return path.
You'll want to get your head around the header part of the mail function (was that a pun?). The manual [php.net] has some examples and links to the relevant RFCs.
Tim