Project:Mail Logger
Version:5.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Great module! I really like this functionality and the css is sharp.

I was wondering if you might consider adding an admin interface to allow users to export the data from the db table to a file?

Basically, the ui would have two fields:

1. Allow the user to determine how often to export the data (maybe a dropdown: weekly, bi-weekly, monthly, etc).
2. Allow the user to set whether the table gets truncated once data exported (to keep the db size down).

Essentially it would only require a cron job such as:

function mail_logger_cron(){
   if (strtotime($frequency)): // "first day" of the month, specific day of the week, etc)
      $mailloggerpath = drupal_get_path('module', 'mail_logger');
      $csscontents = file_get_contents($mailloggerpath  . "/mail_logger.css");
  
      $sql = "SELECT * FROM {mail_logger}";
     
      $result = db_query($sql);
      $datefn = date("Y_m");
      $pathway = file_directory_path();
      $fp = fopen($pathway . "/maillog/" . $datefn . '_maillog.htm', 'w');
      fwrite($fp, "<html>\n");
      fwrite($fp, "<head>\n");
      fwrite($fp, "<title>Email Log for " . date("M Y") . "</title>\n");
      fwrite($fp, "<style type=\"text/css\">\n");
      fwrite($fp, $csscontents);
      fwrite($fp, "</style></head>\n");     

      fwrite($fp, "<h1>Email Log for " . date("M Y") . "</h1>\n");
      while ($get_mail = db_fetch_object($result)){
         fwrite($fp, theme_mail_logger_read_mail($get_mail));
         fwrite($fp, "<br /><br />\n");
      }
      fwrite($fp, "</body></html>");
      fclose($fp);
      if ($do_truncate):
         $sql = "TRUNCATE TABLE mail_logger";
         db_query($sql);
      endif;
   endif;
}
nobody click here