app->moduleManager->get('Admin', 'Api')->setUpServerMailHandler(); $today = new \DateTime('now'); $hasErrorReport = \is_file($file = __DIR__ . '/../../../Logs/' . $today->format('Y-m-d') . '.log'); // @todo define report email template $mail = new Email(); $status = $this->app->moduleManager->get('Admin', 'Api')->setupEmailDefaults($mail); $mail->addTo($mail->from[0]); $mail->subject = 'Error report'; if ($hasErrorReport) { $mail->body = 'Your daily Error report.'; $mail->bodyAlt = 'Your daily Error report.'; $mail->addAttachment($file); } else { $mail->body = 'No errors today.'; $mail->bodyAlt = 'No errors today.'; } if ($status) { $status = $handler->send($mail); } if (!$status) { \phpOMS\Log\FileLogger::getInstance()->error( \phpOMS\Log\FileLogger::MSG_FULL, [ 'message' => 'Couldn\'t send error report mail', 'line' => __LINE__, 'file' => self::class, ] ); } return new NullView(); } }