0

How can I handle this:

We have a Email system based on DOVECOT IMAP, different users, different logins.

I want to somehow rsync all sent folders of some users, so one user can check what another user have written for example to customers. The sent emails should copy to the sent folder of each user designated.

The basic idea is that every user should be able to look in his sent folder to see what he or other have written to the customer. What the customer writes and goes to the INBOX should not be synced. Because the customer may address different topics to each user.

So if the customer address to user1 something, user2 does not need to get in copy. But if the user1 address something to the customer it should be synced to the send folder of the 27 users.

I know this uses a lot of disk space.

I want in the end to have the SENT email of user1, user2 ... usern mixed in all sent folders of this users. I do not want to use a shared folder because that is dangerous, one user can by mistake delete the originals.

So we will need to two-way rsync /home/user1/mail/sent/cur with /home/user2/mail/sent/cur and /home/user1/mail/sent/new with /home/user2/mail/sent/new, what means

rsync -rtu --delete /home/user1/mail/sent/cur /home/user2/mail/sent/cur
rsync -rtu --delete /home/user1/mail/sent/new /home/user2/mail/sent/new

The first problem is how to solve it when I have 27 users?

The second problem are the rights. How can I rsync in a way that the Imap rights are in a way that the copied emails should belong to the owner of the mailbox they are synced to? (Dovecot does not change the rights)

The third problem is that the headers should preserve.

UPDATE 1 I do NOT want to create common folders with ACLs and read write access and reconfigure MUAs to use them as sent folder. This my be the more elegant and complicate solution, but I don't want it.

UPDATE 2 A blind BCC solution is suboptimal because it put the sent emails in the other users INBOX and it changes the headers.

  • 1
    Re. your update: Please look into IMAP ACLs. They have a special permission for message deletion, so if your users don't have this permission, they can't delete mails from this folder. – Sven Aug 7 '14 at 12:35
  • Re your 2nd update: Suit yourself. I explained why your approach is bad and likely will not work at all, so have fun. – Sven Aug 7 '14 at 13:26
1

From the rsync manual:


rsync -avz foo:src/bar /data/tmp

This would recursively transfer all files from the directory src/bar on the machine foo into the /data/tmp/bar directory on the local machine. The files are transferred in "archive" mode, which ensures that sym‐ bolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer. Additionally, compression will be used to reduce the size of data portions of the transfer.


The archive mode is the -a switch. Modifying your comands to:

rsync -artu --delete /home/user1/mail/sent/cur /home/user2/mail/sent/cur
rsync -artu --delete /home/user1/mail/sent/new /home/user2/mail/sent/new

should solve the permissions problem.

  • 2
    Which means you don't exactly want to preserve the permissions. You need a second command then. Write a small script and include both, use chown (e.g chown user.group /path) command to give the files user2 ownership. I still agree with SvWs answer this is not the way to go. Workarounds like this sometimes (surprisingly) do the job, sometimes they behave in very unpredictable ways. – Louis Papaloizou Aug 7 '14 at 14:03
  • Note that this really relies on some intimate knowledge of your IMAP server and how it handles its storage backend (some don't use the filesystem to store individual files, though Dovecot does). It's possible that preserving symlinks may not be what you want in cases like this but that determination is left as a key detail for the implementer (Know Your System - I don't know Dovecot well enough to be sure so this is just a general cautionary note.) – voretaq7 Aug 7 '14 at 21:51
4

That is a terrible approach. An IMAP daemon expects to have full control over its file system structure and manually circumventing this is never a good idea.

Try do use IMAP ACLs instead and allow everyone to read/write a common shared folder and designate this as the sent folder for your MUAs. To make this clear: This approach is not about syncing. With a shared folder and appropriate permissions, you allow user A to read/write user B's folder. If you configure your mail clients (MUA) to use this shared folder as sent folder, everyone just uses this and there is no need for strange workarounds.

Another approach: Create a BCC to a shared account for all outgoing mail. This might also be handled on the MTA level.

  • please be more precise. how can I sync SENT folders using IMAP ACLS? – user1888089 Aug 7 '14 at 11:40
  • 1
    @SvW: good answer. Shared folders is the way to go, since this is an IMAP feature to deal with this kind of situations. – itsafire Aug 7 '14 at 13:23
  • 1
    @eichertc: You choose to ignore our advice and want to actively work around the features offered by your system. Your question has been answered - You don't have to like the answer. – Sven Aug 7 '14 at 13:41
  • 1
    @eichertc Your question has been answered (quite thoroughly). You are not required to like the answer, nor are you obligated to accept it. Imposing additional constraints on your question to invalidate an answer is poor form. If you would like to discuss this further please take it to Meta - comments are NOT the place to grouse about answers you do not like. – voretaq7 Aug 7 '14 at 21:47

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.