1

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!

10
  • stackoverflow.com/search?q=%5Bphp%5D+%5Bemail%5D+not+sending Commented Mar 7, 2012 at 14:48
  • nope couldn't find how to log my php email activity Commented Mar 7, 2012 at 14:51
  • Need more info. What's your hosting situation? Last time this happened to me it was because I upgraded to Windows 7 and didn't have a mail server installed. Commented Mar 7, 2012 at 14:52
  • maybe it is not using as sender the address you need.. did you try to use the 4th parameter adding "From: [email protected]".. or maybe the 5th parameter also using -f and the same address "-f [email protected]" Commented Mar 7, 2012 at 14:54
  • I'm working on a crappy dedicated server with no access to any settings whatsoever... It's basic LAMP. In my admin panel there is no info to be found... Commented Mar 7, 2012 at 14:56

3 Answers 3

1
 <?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 ....

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.