Go Back   HostGator Peer Support Forums > Public Forums > Pre-Sales Questions

Notices

Reply
 
Thread Tools
  #1  
Old 11-16-2005, 12:40 PM
happynewcust
HostGator Guest
 
Posts: n/a
Default php form mail coming from "Nobody"

I have some small php forms in some of my sites. They work fine, I get the emails. I can specify the subject. I have it set up to reply to the email of the person who filled out the form. When I get the form email they come from "Nobody" Can I change that to "your website" or other? If so, how.

Thanks,
great service, great value. Very happy with your reseller package so far.
Reply With Quote
  #2  
Old 11-16-2005, 03:47 PM
Stef's Avatar
Stef Stef is offline
Royal Croc
 
Join Date: May 2004
Posts: 715
Default Re: php form mail coming from "Nobody"

In the php mail function you can set other headers like this:
PHP Code:
...
$subject "Contact form";
$headers "From: your website\n";
...
mail ($recipient$subject$message$headers); 
Stef.
Reply With Quote
  #3  
Old 11-16-2005, 04:29 PM
happynewcust
HostGator Guest
 
Posts: n/a
Default Re: php form mail coming from "Nobody"

This is what I have but no matter what I put for From, it always comes from NOBODY. Tried to do a $_POST['firstname'] also, but no luck. The subject and reply to work like they should. Thought there might be something in the control panel to make this change.
----------------------------->

$recipient = "info@mysite.com";
$subject = "CONTACT FORM from mysite.com";

$mailheaders = "From: Visitor inquiry\n";
$mailheaders = "Reply-To:". $_POST['email']."\n\n";

mail($recipient, $subject, $msg, $mailheaders);

----------------------------->
Reply With Quote
  #4  
Old 11-16-2005, 05:41 PM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,067
Default Re: php form mail coming from "Nobody"

Quote:
Originally Posted by happynewcust
This is what I have but no matter what I put for From, it always comes from NOBODY. Tried to do a $_POST['firstname'] also, but no luck. The subject and reply to work like they should. Thought there might be something in the control panel to make this change.
----------------------------->

$recipient = "info@mysite.com";
$subject = "CONTACT FORM from mysite.com";

$mailheaders = "From: Visitor inquiry\n";
$mailheaders = "Reply-To:". $_POST['email']."\n\n";

mail($recipient, $subject, $msg, $mailheaders);

----------------------------->
You didn't include a from address. If you format it correctly, it will work fine:
$FromName = "user";
$fromemail = "MyEmail@mydomain.com";
$mailheaders = "From: ".$FromName." <".$fromemail.">";
Reply With Quote
  #5  
Old 11-17-2005, 03:37 PM
Stef's Avatar
Stef Stef is offline
Royal Croc
 
Join Date: May 2004
Posts: 715
Default Re: php form mail coming from "Nobody"

Quote:
Originally Posted by happynewcust
$recipient = "info@mysite.com";
$subject = "CONTACT FORM from mysite.com";

$mailheaders = "From: Visitor inquiry\n";
$mailheaders = "Reply-To:". $_POST['email']."\n\n";

mail($recipient, $subject, $msg, $mailheaders);
What you do in your code is putting the From header in $mailheaders and then overwriting $mailheaders with the Reply-To value.
Instead you should concatenate the two headers in the $mailheaders variable:
PHP Code:
$mailheaders "From: Visitor inquiry\n";
$mailheaders .= "Reply-To:"$_POST['email']."\n\n"
Note the dot before = in the second line.

Stef.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 08:32 PM.

 
Forum SEO by Zoints