Dne úterý 25. května 2021 0:31:20 CEST, Vladislav Kurz napsal(a):
Hello,
I'm looking for deduplication of mails via hardlinks during delivery. I.e. a mail that is sent to multiple recipients (to, cc, bcc) should be stored only once.
I did some search and found only some non-complete information.
dovecot-lda has a "-p path" option that does the delivery using symlinks if possible (i.e. same uid/gid and same filesystem). This is working by hand, but could not find any hints how to use this with postfix. Found only suggestion of a wrapper, that was probably never implemented - in this thread: https://dovecot.org/pipermail/dovecot/2008-June/031158.html
In this message: https://dovecot.org/list/dovecot/2013-February/088540.html there is statement that: LMTP always delivers the mail to the first user. Then it tries to copy the first mail to the second user, because in some setups this can be done using hard links.
I was not able to get this in my setup, and I'd like to know if this statement is really true. I have all mail in /var/vmail, all owned by vmail user, but still mail delivered to multiple users is duplicated.
If this is really supposed to make hardlinks (which would be great), is there any way to debug it? E.g. see if the hardlink was attempted but failed for some reason, or if the message was delivered in the same LMTP session ?
I will answer to myself, to provide further information for others bumping into the same issue.
It seems so, that LMTP does hard links, only if the recipients do not have any sieve scripts.
But repeated delivery with "dovecot-lda -p <file> -f <sender> -d <recipient>" makes hardlinks even if users do have sieve scripts.
So I made a wrapper that takes all recipients on command line, mail message on stdin, dumps the mail to tempfile and loops over all recipients with dovecot- lda. So far it seems to be working nice (with postfix as SMTP server).
-- Best regards Vladislav Kurz