Koozali.org: home of the SME Server

How to automaticaly forward a single user outgoing email to an archive?

Offline William R H

  • *
  • 23
  • +0/-0
We have a temporary part-time staff member - I can ensure all his incoming emails are forwarded to our full timers' folder.

But how to get his outgoing ones copied to the same?

I can see how to make copies of all outgoing emails to an archive. But that is not what we want - just emails for this user.

Offline mmccarn

  • *
  • 2,626
  • +10/-0
Re: How to automaticaly forward a single user outgoing email to an archive?
« Reply #1 on: August 14, 2020, 12:27:38 PM »
I can think of a few ways to do this:

1) Add the temp's email to the full timer's email client as a second account

2) Setup Bccmode, then either
   * setup fetchmail with some rules to pull out items sent by the 'temp' and send them to the full timer
   or
   * setup mailfilter rules to forward email 'from' tmpuser to fulltimer
    (I have not tested this)

3) Use rsync to sync the temp's Sent mail into a folder belonging to the full timer.

I tested the rsync option like this:

* Create a destination folder in the full timer's email in Horde ("Test" in my example)
* Use rsync to copy the mail from tmpuser to fulltimer
Code: [Select]
export SRCU=tmpuser
export DSTU=fulltimer
export SRCF=.Sent\ Items
export DSTF=.Test

# pre-create the mailbox in fulltimer's email client so that dovecot creates the indexes correctly

# sync the folders that actually contain email
rsync -avz "/home/e-smith/files/users/$SRCU/Maildir/$SRCF/cur/" "/home/e-smith/files/users/$DSTU/Maildir/$DSTF/cur/"
rsync -avz "/home/e-smith/files/users/$SRCU/Maildir/$SRCF/new/" "/home/e-smith/files/users/$DSTU/Maildir/$DSTF/new/"
rsync -avz "/home/e-smith/files/users/$SRCU/Maildir/$SRCF/tmp/" "/home/e-smith/files/users/$DSTU/Maildir/$DSTF/tmp/"

# change the ownership on the copied email files
chown -R $DSTU:$DSTU "/home/e-smith/files/users/$DSTU/Maildir/$DSTF/"

4. I use Sogo on my server -- I found in Sogo I could 'share' the Sent folder between users.  (The wiki page describes the installation of Sogo 3, but Sogo 4 came out a couple years ago...)

It should also be possible to setup Bccmode with 'per user' config -- but I made that suggestion for this problem 5+ years ago and no one ever published notes on exactly how to get it working...