/** {@inheritdoc} */ protected function sendMail() { $r = $this->app->request; $html = $this->getMailHtml(); $text = strip_tags($html); $mail = new Mail(); $mail->setBodyText($text); $mail->setBodyHtml($html); $mail->setSubject($this->subject); $mail->setFrom($this->from, $this->sender); if ($r->request->get('email')) { $mail->setReplyTo($r->request->get('email')); } foreach (explode(",", $this->to) as $email) { $mail->addTo(trim($email)); } $mail->send(); }
/** * Send error notification email. * * @param Exception $e */ public function sendErrorNotification(Exception $e, Inspector $inspector, Run $run) { try { // Create form to recreate error $method = strtoupper($_SERVER['REQUEST_METHOD']); $hidden = Html::createHiddenFields($method == 'POST' ? $_POST : $_GET); $action = url(URL::getRequestUri())->getAbsolute(); $form = '<form action="' . $action . '" method="' . $method . '">' . $hidden . '<button type="submit">Execute</button></form>'; // Compose mail $content = '<html><body>' . '<h1>' . get_class($e) . '</h1>' . '<h2>' . htmlspecialchars($e->getMessage()) . '</h2>' . '<p><strong>Method:</strong> ' . $method . '<br/>' . '<strong>URL:</strong> ' . $action . '<br/>' . '<strong>File:</strong> ' . htmlspecialchars($e->getFile()) . '(' . $e->getLine() . ')</p>' . '<h2>Recreate</h2>' . $form . '<h2>Trace</h2>' . '<pre>' . htmlspecialchars($e->getTraceAsString()) . '</pre>' . '<h2>Variables</h2>' . '<h3>$_GET</h3>' . '<pre>' . htmlspecialchars(print_r($_GET, true)) . '</pre>' . '<h3>$_POST</h3>' . '<pre>' . htmlspecialchars(print_r($_POST, true)) . '</pre>' . '<h3>$_SERVER</h3>' . '<pre>' . htmlspecialchars(print_r($_SERVER, true)) . '</pre>' . '</body></html>'; // Create and send mail $mail = new Mail(); $mail->addTo($this['adminEmail']); $mail->setSubject('Error on ' . $this['name']); $mail->setBodyHtml($content); $mail->send(); $this->logger->info('Sent error notification'); } catch (Exception $e) { $this->logger->error('Failed to send error notification'); } return Handler::DONE; }