2

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?

  • 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
5
+25

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 them 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
2

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.

  • 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 '14 at 14:09
-1

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
  • what's the reason for the downvote? while this does not answer the question directly, it provides a hint to solve the underlying problem. – umläute Dec 13 '16 at 14:48
-2

When you use pop3 and Maildir will contain one large text file.Because all incoming messages stored in one large file. When you use imap and Maildir will contain many small text file.Because each incoming message stored in seperate text file.

  • POP3 and IMAP are protocols used to access the messages. They do not govern how those messages are stored to disk on the mail server. In fact, the same mail server will often be accessible via both POP3 and IMAP, so it is obviously impossible for the storage format to depend on which access protocol is in use. – Kevin Jun 24 '17 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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