When some users switch to a new email naming policy, they may need to duplicate email content. This process can be very demanding in terms of inodes and memory space.
In my experience, one client had over a hundred addresses. They needed to retain the old email addresses while maintaining a complete history of previous emails and setting up forwarding.
The transitions were as follows:
- [email protected] => [email protected]
- [email protected] => [email protected]
- [email protected] => [email protected], [email protected]
We use Maildir, and to avoid content redundancy. I wrote a basic script with the understanding that mail operations won’t alter the original emails. As the user can only:
- Remove the email message, which will result in the removal of the symlink.
- Or move the email message from one directory to another (e.g., Inbox => Archive, or Trash); which will be interpreted as moving the symbolic link to the directories .archives/cur or .trash/. Since we use full paths to describe the links, this won’t cause any issues and won’t alter the original files.
I have also excluded some maildir system files from being linked, starting usually with dovecot* or maildir*.
The script usage is straightforward:
./mailinker.sh mycpuser [email protected] [email protected]
Continue reading