Mailsorting

From SME Server
Jump to navigation Jump to search

Sorting mail with Maildrop or Procmail

yum install smeserver-mailsorting --enablerepo=smecontribs

Allows a user to configure mail rules with the UserManager

Procmail or maildrop is used to process your email on the server. It follows user defined rules. Common uses are to sort mail into folders or forward selected email on to other email addresses. The rules that you define are executed as email arrives in your mailbox on the server, and are independent of your email client. If you sort to folders you will need to use a IMAP mail client to read them.


Rule List

The panel shows a table of active rules and the order they are executed in. Each rule has links to modify or remove them.

A yes* in 'copy to' copies the email to your inbox


Create Rules

A user defines a pattern for emails that if matched, an action occurs.


  Note:
Defining a mail rule that includes characters such as '[','{','.',']','}' breaks the sort rules and standard mail deliveray in general. It is necessary to escape these special characters in the mail rules so that the sort rules work correctly.


Configuration

Enable mailsorting

Use either procmail or maildrop

db configuration setprop qmail FilterType procmail
db configuration setprop qmail FilterType maildrop
db configuration delprop qmail FilterType [delete to disable]

If you want to bypass filtering for an individual user

db accounts setprop user MailFilter bypass
db accounts delprop user MailFilter [delete to disable]

after any command

signal-event mailsorting-conf

Any mail that passes through procmail or maildrop without matching a rule is delivered according to the existing user setting.
ie. deliver locally, forward or both.


Deleting duplicates

Procmail will automatically delete duplicate email.

Maildrop has to be enabled at the command line

Individually

db processmail setprop USERNAME deldups yes 
signal-event mailsorting-conf 

To enable for all users

db processmail setprop maildrop deldups yes
signal-event mailsorting-conf 


Create a global rule

db commands

It's possible just to use db commands, here is a subset of options

db processmail setprop 50001 pmGlobalRule action delete basis subject criterion xyz

50001: is the rule precedence

action: is either - sort delete forward

basis: match against this - headers Subject To From

criterion: using the text entered here - 'xyz'


fragments

For more flexibility create a fragment in templates-user, expand template as above

Testing

Create a simple rule, eg Subject = xyz > forward to USER2

Send an email to USERNAME to match, check in USER2's inbox

View the logs

For Maildrop

tail -50 /home/e-smith/files/users/USERNAME/mailfilter.log or

For Procmail

tail -50 /home/e-smith/files/users/USERNAME/procmail.log