mail()不是邮件

$mailHeaders = "From: webmaster@{$_SERVER['HTTP_HOST']}
" .
            "Reply-To: myemail@gmail.com
" .
            "X-Mailer: PHP/" . phpversion();
if (!mail($tol, $subject, $mailMessage, $mailHeaders))
{
    echo "<br />Mail failed to send. Sorry.";
}

It isn't echoing the Mail failed to send. Sorry., so I know its sending. But I'm not receiving it in my inbox. I can't figure out why.

Aha, found a mailqueue, and found the emails there. Tried to send them again and I got this:

retry time not reached for any host

Can you guys close this to move to serverfault, please? :)

Have you checked your spam folder? I've run into that issue before...

If its a VPS, I am guessing you have SSH access. I would try

tail -f /var/log/mail.*

To see what the box is doing with your mail.

Some mail servers are very tricky to manage.

PHP Mailer saved my life with its simple to use plugin. Takes all the complication and mystery out of PHP email. It makes HTML emails a doddle and also makes mail attachment very simple. Try it out.

I had the same problem of no emails actually being senyt. To get round my problem (which mainly lay with my server Go Daddy) I had to communicate with the SMTP Host address directly. That was the only way I could get my emails out of the Go Daddy server. So in other words almost setting up my PHP email in a similar way as you would set up an email account in Outlook. Except using my server's public SMTP gateway.

http://phpmailer.worxware.com/

Hope this gets you closer to your solution!

W.

Dumb suggestion: preview your vars for the mail function, try echo $tol, $subject, $mailMessage, $mailHeaders; before the if condition.