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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
surath
Forum Newbie
Posts: 14
Joined: Fri Jun 15, 2007 8:59 am

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

Post 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 :)
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

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

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

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

Post 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.
Post Reply