DoveCot, move messages from certain domains to folder: Difference between revisions

From Andreida
No edit summary
No edit summary
 
Line 1: Line 1:
= Goal =
We will assume the user you are creating filters for is "petra". Petra does not want to see messages from certain domains (corporations) but does want to keep them for a while in her trash, so she can find them if someone calls her and references "his mail from yesterday".
We will assume the user you are creating filters for is "petra". Petra does not want to see messages from certain domains (corporations) but does want to keep them for a while in her trash, so she can find them if someone calls her and references "his mail from yesterday".


= Possible destination folders =
Get a list of folders
Get a list of folders
ls -d /home/petra/Maildir/.*
ls -d /home/petra/Maildir/.*
Line 15: Line 17:
What you get may differ. If - for example - you use Outlook, chances are your output is completely different. That is NOT important. Important is to know what DoveCot works with. So, our target folder for this example is "/home/petra/Maildir/.INBOX.Trash".
What you get may differ. If - for example - you use Outlook, chances are your output is completely different. That is NOT important. Important is to know what DoveCot works with. So, our target folder for this example is "/home/petra/Maildir/.INBOX.Trash".
Inside the filter we will use the "save" command. If given a relative destination, it will insert the home folder of the current user before the given folder. So we will just use "Maildir/.INBOX.Trash/" to be able to copy the file from user to user.
Inside the filter we will use the "save" command. If given a relative destination, it will insert the home folder of the current user before the given folder. So we will just use "Maildir/.INBOX.Trash/" to be able to copy the file from user to user.

= .forward file =


We create a ".forward" file in the home directory of Petra. Could be something like
We create a ".forward" file in the home directory of Petra. Could be something like
Line 22: Line 26:


chown petra:petra /home/petra/.forward
chown petra:petra /home/petra/.forward

== filter ==


We want a filter for Domain.bad.1 and Domain.bad.2.
We want a filter for Domain.bad.1 and Domain.bad.2.

Latest revision as of 14:31, 8 March 2019

Goal

We will assume the user you are creating filters for is "petra". Petra does not want to see messages from certain domains (corporations) but does want to keep them for a while in her trash, so she can find them if someone calls her and references "his mail from yesterday".

Possible destination folders

Get a list of folders

ls -d /home/petra/Maildir/.*

You will see something like this:

/home/petra/Maildir/.INBOX
/home/petra/Maildir/.INBOX.Trash
/home/petra/Maildir/.INBOX.Archives
/home/petra/Maildir/.INBOX.Sent
/home/petra/Maildir/.INBOX.Templates
/home/petra/Maildir/.INBOX.Junk
/home/petra/Maildir/.INBOX.Drafts

What you get may differ. If - for example - you use Outlook, chances are your output is completely different. That is NOT important. Important is to know what DoveCot works with. So, our target folder for this example is "/home/petra/Maildir/.INBOX.Trash". Inside the filter we will use the "save" command. If given a relative destination, it will insert the home folder of the current user before the given folder. So we will just use "Maildir/.INBOX.Trash/" to be able to copy the file from user to user.

.forward file

We create a ".forward" file in the home directory of Petra. Could be something like

vi /home/petra/.forward

The ownership of the ".forward" file is important. If you just copy the ".forward" file and don't modify the ownership, the ".forward" will not be used.

chown petra:petra /home/petra/.forward

filter

We want a filter for Domain.bad.1 and Domain.bad.2. This is the .forward file:

 # Exim filter
 if  $sender_address contains @domain.bad.1 or
     $sender_address contains @domain.bad.2
 then
     save Maildir/.INBOX.Trash/
 endif