shameless self-promoting website
»Rejourn root
Posted Monday, 11 January 2010 by Miklos
Tags: en hacking

Say you have two servers, the first is just a mail proxy, the second is a real mail server. So the MX record points to the first box and you usually just read your mail on the second one.

We use this system at frugalware.org as well to make the service a bit more robust: if genesis (the "second" box) goes down, the proxy machine(s) can just queue up the input and in case one of the proxy machines go down, then the sender will just try an other proxy.

The problem occurs when the "second" box goes down and you need to read your mail ASAP. Let's say you have access to the first box. You see in the output of 'mailq' that there are messages in the queue but how to read those mails?

'mailq' gives the ID of each message, and then the following script (I call it 'mails' - s for show) can generate mbox format from it, which means you can read it with for example 'mutt -f foo.mbox'.

The script itself is fairly easy:


echo 'From news@gmane.org Tue Mar 04 03:33:20 2003' |sed '1,/^\*\*\* MESSAGE CONTENTS/d;/^\*\*\* HEADER EXTRACTED/,$ d'

(And of course it's possible there is a better tool to do the job, but I use this for months now.)