echo '<pre>'; print_r($sendReportsTo); if (is_array($sendReportsTo)) { if (!empty($sendReportsTo)) { foreach ($sendReportsTo as $ars => $user) { $mail = new Zend_Mail(); $mail->setFrom('*****@*****.**', 'Textmunication.com'); $mail->addTo($user['email']); $mail->setSubject('Monthly Reports'); // Get the Excel model // $excelDataArray = array(); $excelFile = ""; if ($weeklyreport->checkAdminUser($user['id']) and $user['id'] != 187) { if ($user['edituser'] != '0') { $prmonth = date('Y-m', strtotime("last month")); $excelDataArray = $weeklyreport->getMonthlyReportApiuser($user['id']); echo $excelFileName = $user['topic'] . "_monthly_report_" . $prmonth; logWrite("Creating the Excel spreadsheets"); $excel = new Application_Model_Excel(); if (isset($excelDataArray)) { $excelFile = $excel->create($excelDataArray, $excelFileName); logWrite("Attaching the spreadsheets"); $at = $mail->createAttachment(file_get_contents($excelFile['path'])); $at->filename = $excelFile['name']; sleep(3); } else { continue; } } } // Log the steps