cmplieger
cmplieger

Reputation: 7371

PHP mail script does not send mail

I have this mail script on my page: mail('[email protected]', 'New client added by user', 'test message'); but I do not receive anything! (of course I added my real adress). I tried it with 2 different adresses, looked in my spam folder, etc... just nothing. but the script executes just fine.

Is there any log I can view or invoke to see exactly what happened?

thank you for your help!

Upvotes: 1

Views: 238

Answers (3)

epicwebsol
epicwebsol

Reputation: 25

 <?php
$to = "[email protected]";

$subject = "Test mail";
$message = "Hello! This is a simple email message.";

$from = "[email protected]";


$headers = "From:" . $from;


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

echo "Mail Sent.";

?>

try this it will going to work for u ....

Upvotes: 1

cmplieger
cmplieger

Reputation: 7371

Had to add the header "from" and use an email adress created on the server.

Upvotes: 0

Marc B
Marc B

Reputation: 360872

1) Check the return value from the mail() call:

$status = mail(...);
if (!$status) {
    die("Mail failed");
}

If this fails, then PHP cannot even get the mail out the front door, and you'll have to figure out why - e.g. are you on a Windows box and haven't configured the mail options in php.ini?

2) Check your mail server's logs. Most Unix/Linux systems have a local mail server (the MTA) which will accept the mail from PHP. If it's misconfigured or having trouble, it may still accept the mail from PHP but then leave the mail to rot in a queue.

Perhaps your server's been placed on spam blackhole lists and it simply cannot deliver mail anywhere, which means you've probably got all of your test mails stuck in an outgoing queue that can't go anywhere.

Upvotes: 0

Related Questions