Page 1 of 1

how to get the no. of bounced mails in php?

Posted: Thu Feb 21, 2008 12:08 am
by surath
Hi all,

I've a situation like this:

I've a page where I'm entering number of email ids and then sending mails to those ids. Now, I've to find out the number of bounced mails in this case (I mean number of those mails which are failed to be sent).

Anyone there to help me ? I'm completely in dark.

Thanks in advance :)

Re: how to get the no. of bounced mails in php?

Posted: Thu Feb 21, 2008 12:28 am
by s.dot
I doubt you'll get your solution using php.

Are you talking about bounces, too? mail() will return false on failure, so:

Code: Select all

$failed = 0;
foreach ($emails AS $email)
{
    if (!mail(...))
    {
        $failed++;
    }
}
 
echo $failed . ' emails failed to send';
However, I highly doubt that's what you're looking for.

Re: how to get the no. of bounced mails in php?

Posted: Thu Feb 21, 2008 1:28 am
by Kieran Huggins
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 deal with messages bouncing, you'll have to use the IMAP functions to check the account they're bounced to.