public function run($request)
 {
     if (Permission::check('ADMIN')) {
         $since = date('Y-m-d H:i:s', strtotime('-1 month'));
         $list = CapturedEmail::get()->filter('Created:LessThan', $since);
         echo "Deleting " . $list->count() . " captured emails (if confirm flag set)<br/>\n";
         if ($request->getVar('confirm')) {
             $list->removeAll();
         }
     }
 }
 /**
  * Send a multi-part HTML email
  * TestMailer will merely record that the email was asked to be sent, without sending anything.
  */
 function sendHTML($to, $from, $subject, $htmlContent, $attachedFiles = false, $customHeaders = false, $plainContent = false, $inlineImages = false)
 {
     if (self::$capture_emails) {
         $mail = new CapturedEmail();
         $mail->To = $to;
         $mail->From = $from;
         $mail->Subject = $subject;
         if (is_array($customHeaders)) {
             foreach ($customHeaders as $header => $val) {
                 $mail->Headers .= "{$header}: {$val} \n";
             }
         }
         $mail->Content = $htmlContent;
         $mail->PlainText = $plainContent;
         if ($this->send) {
             $mail->SendID = $this->send->ID;
         }
         $mail->write();
     }
     if (self::$outbound_send) {
         return parent::sendHTML($to, $from, $subject, $htmlContent, $attachedFiles, $customHeaders, $plainContent, $inlineImages);
     }
     return true;
 }