View Full Version : Php mail

09-10-2009, 05:13 PM
Hi i have this php mail script and it says message sent successfuly but i never recieve the message.
any help apreciated.

i know my email address needs to go where "you@someone.com" is so thats not the problem.

$to = "you@someone.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");

09-10-2009, 05:16 PM
could be a few things.

a) have you checked your spam folder?
b) is apache/linux correctly configured with with sendmail?

c) try adding headers:

$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

09-10-2009, 05:18 PM
headers doesn't work.
how can i check if it is configured correctly.

09-10-2009, 05:20 PM
what do you mean headers don't work? in what way do they not work??

yes, normally a good test would be to use the mail function which you are trying now.

use the default script that I posted ( right from the manual ), configure it with your email address and test it. post back if theres an error.

09-10-2009, 05:22 PM
i used the script you posted but still no luck. it doesn't say theres any errors i just don't recieve the email

09-10-2009, 05:23 PM
did you get an error? and did you check your spam folder?

09-10-2009, 05:23 PM
no errors and yes i checked my spam folder.

09-10-2009, 05:25 PM
hmm, not sure what I can do for you then, you can try and call your host and have them look into this. also it may be that your host/server ip has been black listed. but as for the php itself. it should work as is.

09-10-2009, 05:26 PM
ok thanks for your help