Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using postfix with maildir format. The filenames of messages stored in maildir look something like this:

1386021659.27745_1.alpha:2,S

I understand the first part is epoch time, not sure about the rest. But I would like to have some human friendlier name, such as

2013-12-18__120502.sender_or_subject_of_the_message:2,S

I need to manipulate the individual messages/files often (this is the reason why I am using maildir in the first place). Having some more descriptive filename would help.

Can I set this in postfix?

share|improve this question
    
What program is doing the actual mail delivery (e.g. procmail)? That is probably where you need to look rather than the MTA. –  casey Dec 18 '13 at 14:43
    
AFAIU, postfix is doing the actual mail delivery to my maildir folder. –  Martin Vegter Dec 18 '13 at 14:58

3 Answers 3

No, Postfix has no way to configure this. As @HBruijn said, the Maildir format is a specification and it would be quite an effort to make the LDA and the MUA both agree on a different format. That said, if you don't like the filenames in your maildir, you could beautify them a bit when you look then up:

$ ls | head -1
1325471944.27745_1.beta,S=10662:2,S

$ ls | head -1 | perl -pe 's/(\d+)/localtime($1)/e'
Mon Jan  2 03:39:04 2012.27745_1.beta,S=10662:2,S
share|improve this answer

The original specification of the Maildir format would be good start to answer your question.

The requirement is that each new message will be stored with a unique name.

Unless you're writing messages to a maildir, the format of a unique name is none of your business.

A unique name can be anything that doesn't contain a colon (or slash) and doesn't start with a dot. Do not try to extract information from unique names.

Okay, so you're writing messages. A unique name has three pieces, separated by dots. On the left is the result of time() or the second counter from gettimeofday(). On the right is the result of gethostname(). (To deal with invalid host names, replace / with \057 and : with \072.) In the middle is a delivery identifier, discussed below.

...

Old-fashioned delivery identifiers use the following formats for the delivery identifier: :

  • n, where n is the process ID, and where this process has been forked to make one delivery. Unfortunately, some foolish operating systems repeat process IDs quickly, breaking the standard time+pid combination.
  • n_m, where n is the process ID and m is the number of deliveries made by this process.

Now the second part of your question, simply put the unique filename is not something that you can configure, unless you go and modify the source code of the local delivery agent.

A work-around would be .forward and pipe the email to script that will store the message with filenames to your liking, essentially creating your own local delivery agent. That should be fairly trivial.

share|improve this answer
    
that is very nice, but how can I configure postfix to use my format? –  Martin Vegter Dec 18 '13 at 15:44
    
add .forward with | /home/vegterm/bin/storemail which is a script that takes the mail message as STDIN and creates filenames to your liking in your Maildir. –  HBruijn Dec 18 '13 at 16:16
1  
+1 and the OP should really rethink on why he wants this so badly. it's like asking for "random numbers but they must start with 3" –  umläute Jan 23 at 14:09

if you "need to manipulate the individual messages/files often" then you might consider writing a script that helps with manipulating them.

as a side-effect your script might expose a human-readable interface to the actual filenames. something like:

dowithmails rm --from 2014-01-12  --to 2014-01-15
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.