Web host email Address in PHP Mail

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
dv_evan
Forum Commoner
Posts: 42
Joined: Wed Apr 09, 2008 8:23 am

Web host email Address in PHP Mail

Post 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
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Web host email Address in PHP Mail

Post 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" );
dv_evan
Forum Commoner
Posts: 42
Joined: Wed Apr 09, 2008 8:23 am

Re: Web host email Address in PHP Mail

Post by dv_evan »

Hi Apolo,

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

Thks again, appreciated.

Dave Even
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Web host email Address in PHP Mail

Post by Apollo »

Neat. Just curious, what did you have to change?
Post Reply