Question : PHP Mail()

Hi guys, I'm tryiing to get a page to automatically send an email telling people that someone posted a comment on an article. I do not know much about email, but this is my first attempt with doing mail(). I tried running this bit of code on my "localhost," but I did not get an email from it to my email  address that I tried to send it to. Could someone please point me in the right direction and help me out with this code?

Thanks!
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:

							
							  Birthday Reminders for August
							
							
							  

There is a new comment on ".$row[2]."'s advice.Click here to check it out!

"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: '.$_SESSION[CLS][userid].' <'.$row[2].'>' . "\r\n"; $headers .= 'From: New comment ' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); } } ?>

Answer : PHP Mail()

Do you have a hosting account where you are planning to run this?  If so, try testing there instead of on your own computer.  They will most likely have the correct PHP installation for this sort of thing.

Also, you can test the return code from mail() to see if it worked.  If you put error_reporting(E_ALL) into your script, you may find notices or other messages that would be a helpful clue.

Also, we cannot see what is in here:  WHERE s.signee = '$_GET[author_id]'";  - so it is possible that the query returned nothing.  It would be useful to add some var_dump() commands to the stream to be sure you have valid data all along the way.

HTH, ~Ray
Random Solutions  
 
programming4us programming4us