Simple mail() question

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
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Simple mail() question

Post by Skara »

Code: Select all

error_reporting(E_ALL);
 
$to = 'example@gmail.com';
$headers = "From: no-reply@example.com\r\nReply-To: no-reply@example.com\r\n";
 
if (mail($to,'test','testing',$headers)) echo 'ok';
Am I doing something incredibly stupid? The output I get is 'ok.' No error messages. It doesn't work. I get no email. My host (retarted people) says that there's a problem with my code. Am I crazy or are they?

Thanks.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Simple mail() question

Post by Chalks »

when you email to gmail accounts, you need to end your headers with "\r\n\n" otherwise, the headers end up in the message body. Other than that, looks fine to me.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Re: Simple mail() question

Post by Skara »

Thanks. I didn't think I was crazy, but it's nice to be told that.
Post Reply