Mail() function always return's true

When ever im sending a mail even to an address like
“dshghdfhdf@sdhdsfhhdfdhf.dhfdfhhdf”
the mail function always returns true…
and since im building a NewsLetter script I need to know
how many was sent and how many failed…

This is the function I use:


function sendHTMLemail($to, $subject, $from, $body) { 
if (ereg("(.*)< (.*)>", $from, $regs)) {
	   $from = '=?iso-8859-8?B?'.base64_encode($regs[1]).'?= < '.$regs[2].'>';
	} else {
	   $from = $from;
	}

    $headers = "From: $from\\r\
";
    $headers .= "MIME-Version: 1.0\\r\
";
    $boundary = uniqid("HTMLEMAIL");
    $headers .= "Content-Type: multipart/alternative;".
                "boundary = $boundary\\r\
\\r\
";
    $headers .= "This is a MIME encoded message.\\r\
\\r\
";
    $headers .= "--$boundary\\r\
".
                "Content-Type: text/plain; iso-8859-8\\r\
".
                "Content-Transfer-Encoding: base64\\r\
\\r\
";
    $headers .= chunk_split(base64_encode(strip_tags($body)));
    $headers .= "--$boundary\\r\
".
                "Content-Type: text/html; charset=iso-8859-8\\r\
".
                "Content-Transfer-Encoding: base64\\r\
\\r\
";
    $headers .= chunk_split(base64_encode($body)); 

    $result = mail($to,'=?iso-8859-8?B?'.base64_encode($subject).'?=',"",$headers);
    return $result;
}

p.s
when ever I use this function to send my real mail it sents it with no problem

The manual on the [fphp]mail[/fphp] function does say:

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

If you want to know whether mail was succesfully delivered you need to setup a script to catch and process bounce e-mails.

Take a look at the BounceHandler class: http://www.phpclasses.org/package/2691-PHP-Parse-bounced-e-mail-message-reports.html

Actually you need to reset your return result then you will know how many emails are going correctly or use variables for holding values for true and false.

Mark
<snip/>

mark15, I am counting how many false, and how many trues I got with that code


while(...)
if (sendHTMLemail(...))
 $success++;
else
 $error++;

the problem is it always returns true
even I send it to an email like “ababababbababab@asdbgbgdsb.asfafsfas”

Scallio, Thanks I will sure take a look to see if that helps me

Then you should initialize your variables before entering loop.

Mark

variables like this

$success = 0
$error = 0

Mark
<snip/>