Page 1 of 1

Web host email Address in PHP Mail

Posted: Sun Jul 13, 2008 12:24 pm
by dv_evan
Dear All,

I have created a form and PHP script to send our emails from my website hosted on Hostgator shared package.
The emails went out fine however the problem for me is that when received these mails are showing that they were sent from the web hosting admin email (admin@gator375.hostgator.com). I would like it to show that it came from my email address and get rid of that hostgator address. Any advise or instructions?

Looking forward to your assistance.
thanks
Dave Evan

Re: Web host email Address in PHP Mail

Posted: Sun Jul 13, 2008 1:07 pm
by Apollo
I assume you send the mail with php's mail function? Maybe your provider's SMTP server fills in certain fields if you don't explicitly specify them yourself. Try sending the mail like this:

Code: Select all

function SendMail( $toAddress, $subject, $body, $fromAddress )
{
 $headers = "From: $fromAddress\r\nReply-to: $fromAddress\r\nReturn-path: $fromAddress";
 return mail($toAddress,$subject,$body,$headers,"-f$fromAddress");
}
 
SendMail( "your@momma.com", "Hello!", "Happy birthday mom", "dave@yourwebsite.com" );

Re: Web host email Address in PHP Mail

Posted: Sun Jul 13, 2008 2:30 pm
by dv_evan
Hi Apolo,

Thanks, with some slight modification I got it to work.

Thks again, appreciated.

Dave Even

Re: Web host email Address in PHP Mail

Posted: Sun Jul 13, 2008 3:28 pm
by Apollo
Neat. Just curious, what did you have to change?