Forum Moderators: coopster
$Success = mail('email@email.com', 'subject', 'message');
if ($Success) {
echo "email was sent"; }
else {
echo "email was not sent"; }
now, this script should write out "email was not sent" because the adress email@email.com obviously does not exist, nor do any other invalid emails i've tried. but the script always types out "email was sent" regardles of wether the message was sent or not.
how do i make it so that if the email address does not exist, it spits back an error message?
i'm using php5 on mac osx server 10.3.8
I found this message in the notes of the php.net/mail page:
Mac OS X users will need to "enable" sendmail (v10.2 and earlier) or postfix(v10.3). Otherwise mail sent with mail() will just que up on your computer and never be delivered anywhere. You will receive no error regarding this from php as php is doing its job just fine.
Sounds like it could be your problem.
Cheers,
Birdman
There are also PHP methods for checking that a MX record exists for the email domain, but even that's not perfect, and will never tell you if the username is valid.
;)