Jan 19 2012

A cheat sheet

I really should use this blog for keeping track of things a bit more.

Here’s one that has helped a few times for me.


Jan 3 2012

33 Weeks

Not long now..

Array

Array


Dec 14 2011

Split mbox file into individual files and pass back into exim via -t


As far as I know, there is no easy way to get exim to reprocess the emails stored in the mbox file located in /var/spool/mail/username. You can copy and paste individual emails into “exim -t” however.


Searching around with Google I came across a PerlMonks post about splitting the mbox file into individual files, exactly what I wanted!


perl -ne 'if(/^From /){open F,">msg".++$m}print F' mbox

Simply replace ‘mbox’ with the name of mbox file (in this case, “jason”), and you end up with a whole heap of “msgx” and “msgxx” files in the same directory.


Since I’m lazy, I just passed each file manually as there was only about 20 emails. You could easily whip up your own script (maybe modify the above perl script!) to pass them in “automagically”.


jason@server:~/temp$ perl -ne 'if(/^From /){open F,">msg".++$m}print F' jason
jason@server:~/temp$ ls -lah
total 1.9M
drwxr-xr-x 2 jason jason 4.0K 2011-12-14 13:27 .
drwxr-xr-x 11 jason jason 4.0K 2011-12-14 13:27 ..
-rw-r----- 1 jason jason 896K 2011-12-14 13:13 jason
-rw-r--r-- 1 jason jason 116K 2011-12-14 13:27 msg1
-rw-r--r-- 1 jason jason 25K 2011-12-14 13:27 msg10
-rw-r--r-- 1 jason jason 15K 2011-12-14 13:27 msg11
<snip>
jason@server:~/temp$ sudo su -
server:~# cd /home/jason/temp/
server:/home/jason/temp# exim4 -t < msg1
server:/home/jason/temp# exim4 -t < msg10
server:/home/jason/temp# exim4 -t < msg11