How can I check a problem with mail being sent on my server? I run a simple test:
if(mail($to, $subject, $message)) {
echo 'Mail Sent';
}
which the test outputs the text; but, no mail ever arrives.
How can I go about tracking down the issue?
If it's still not working: change the sender ($sender) to a local email (use the same email as used for recipient). Upload the modified php file and retry. Contact your provider if it still does not work. Tell your provider that the standard php "mail()" function returns TRUE, but not mail will be sent.
Try changing your headers to this: $headers = "MIME-Version: 1.0" . "\r\n"; $headers . = "Content-type: text/html; charset=iso-8859-1" .
Make sure the localhost mail server is configuredWithout one, PHP cannot send mail by default. You can overcome this by installing a basic mail server. For Windows you can use the free Mercury Mail. You can also use SMTP to send your emails.
On a *nix machine, the PHP mail() function does not support SMTP, but instead uses the sendmail() or other configured mail script on the server.
That is quite a long story. A few bullet points (Assuming that mail() returns true and there are no errors in the error log) :
For german speakers, I have written a quite exhaustive "what to do" on this issue some time ago. See here.
Following Myles, if you are on a Linux box, do this on the command line:
# echo “Body text.” | mail -s “Hello world” [email protected]
If you don't receive that email, you have a problem with the mail system on that box. That is a different question from the PHP question you asked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With