Archiving Mail

Julian Field MailScanner at ecs.soton.ac.uk
Tue Jan 11 09:14:22 GMT 2005


    [ The following text is in the "ISO-8859-1" character set. ]
    [ Your display is set for the "US-ASCII" character set.  ]
    [ Some characters may be displayed incorrectly. ]

Julian Field wrote:

> Jameel Akari wrote:
>
>> While we're on the subject of the Archive function and the fact that it
>> can dump to an mbox file, is there a way to tell MailScanner to use a
>> new
>> mbox file while it is running?
>
>
> Your best bet is to HUP MailScanner and then immediately move new mbox
> files into place. It takes a second or two before the first message will
> be processed, which should give you enough time to get the new mboxes in
> place.
>
> Though obviously this isn't as "Solid" as it should be, I quite agree.
> Ideally you should stop and restart.
>
>> Or perhaps you can have some sort of rule or macro define that
>> filename so
>> that it automatically switches to a new file each day, something like:
>> archive_$DATE.mbox -> archive_20040110.mbox for today,
>> archve_20040111.mbox for tomorrow, etc.  Then you only work on the
>> rotated-out file.
>
>
> That's not a bad idea, but makes it ever more complex to use and
> configure.

I have implemented this in the attached patch for Message.pm. You can
put the magic string
_DATE_
anywhere in the "Archive Mail" setting (more than once if you want to).
This keyword will be replaced with the current date in yyyymmdd format
when the archive is written.

Let me know how you get on.

--
Julian Field
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654


------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!

    [ Part 2: "Attached Text" ]

--- Message.pm.old      2005-01-10 18:46:10.000000000 +0000
+++ Message.pm  2005-01-11 09:05:58.000000000 +0000
@@ -205,6 +205,14 @@
   # Work out where to archive/copy this message.
   # Could do all the archiving in a different separate place.
   $archiveplaces = MailScanner::Config::Value('archivemail', $this);
+  if ($archiveplaces =~ /_DATE_/) {
+    # Only do the work for the date substitution if we really have to
+    my($day, $month, $year, $date);
+    ($day, $month, $year) = (localtime)[3,4,5];
+    $date = sprintf("%04d%02d%02d", $year+1900, $month+1, $day);
+    $archiveplaces =~ s/_DATE_/$date/g;
+    #print STDERR "Archive location is $archiveplaces\n";
+  }
   @{$this->{archiveplaces}} = ((defined $archiveplaces)?split(" ", $archiveplaces):());

   bless $this, $type;

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!



More information about the MailScanner mailing list