On Sat, Jun 14, 2014 at 02:07:17PM +0200, Martin Vegter wrote:
> I am using postfix with maildir format. The filenames of
> messages stored in maildir look something like this:
> 
>   1402593073.Vfe00I75441M583245.alpha:2,S
> 
> where
> the filename is subdivided into three pieces, separated
> with dots:
> 
>   <time>.<delivery_identifier>.<hostname>
> 
> As I see it, the whole point of the filename format
> specification is to ensure that it is unique. But
> unfortunately, the format is not very human readable. I
> need to manipulate messages as files in the filesystem
> (that is the sole reason why I am using maildir in the
> first place). My preferred format would look something
> like this:
> 
>   2014-06-14__14-01-23.sender_subject.hostname
> 
> I have verified that my email client (mutt) is happy
> with this format.

The filenames do not matter to a maildir-speaking client. But the
message flags will be appended with the colon part.
 
> This format would make it much easier for me to copy
> individual messages/files around
> 
> I understand that there is no easy way to achieve this. But
> I want to ask nevertheless, if somebody could recommend best
> approach.

If you can't find any software which does this, you will need a 
custom delivery agent to do it.  Some of it will be easy (like to 
generate the timestamp, and to receive the envelope sender from 
pipe(8) command line), but then it gets hard.

You'll have to read and parse the message headers to extract the
Subject: header.  No, that's not a pipe option.  You'll have to
decode that header, possibly in one of several poorly-documented 
methods.

What will you do if there is no Subject: header?  It is not
required.

What will you do if the same sender/subject hits you multiple
times, all in the same second?  These names MUST be unique. You
might have multiple instances of the same delivery agent running 
simultaneously.  (The agent's PID could help with this.)

The Postfix side of it is documented in the pipe manual to which
reference was made above, or you can visit it online:
    http://www.postfix.org/pipe.8.html

As for the decoding of Subject: headers, I don't know, but you
could start by consulting the source code of a recent and well-
maintained open source MUA.
-- 
  http://rob0.nodns4.us/
  Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:

Reply via email to