/** * Returns all bounces * * @param int $id The id of the campaign. * @return array */ public static function getBounces($id) { // get campaignmonitor ID $cmId = self::getCampaignMonitorID('campaign', $id); // get all bounces from CM $bounces = BackendMailmotorCMHelper::getCM()->getCampaignBounces($cmId); // get all addresses $addresses = BackendMailmotorModel::getAddressesAsPairs(); // no bounces found if (empty($bounces)) { return array(); } // loop the bounces, check what bounces are still in our database foreach ($bounces as $key => $bounce) { // check if the bounced address is in the full list of addresses if (!in_array($bounce['email'], $addresses)) { unset($bounces[$key]); } } // return the bounces return (array) $bounces; }