To filter mail into specific folders, first create the new folder in your mail client. Next, login to the shell. Open the file '.mailfilter' in nano, and you're all set.
$ ssh -p number username@www.acrewoods.net Password: xxxxxx username@acrewoods:~$ nano .mailfilter
You should now have the mailfilter file open. At the top you'll see some defaults, along with at least one filter already defined (e.g. the SPAM filter). The SPAM filter is a good guide to the general format of filters:
# SPAM
if ( /^X-Spam-Flag: YES/ )
{
exception {
to "Maildir/.INBOX.Spam"
}
}
The first line is a comment - it's handy to stick one in for each filter to remind yourself of what it's for. The second line defines which emails it will catch and filter; in the SPAM example, it catches emails with the X-Spam-Flag set to 'YES' in the header. The other important line is the fifth, which defines where the email will be sent if the condition is met (in this case, into .INBOX.Spam, i.e. the folder 'Spam' inside the inbox.
So to add your own filter, simply copy an existing filter, paste it into the bottom of the file, and edit it.
In general, the condition wants to follow the same format as the spam example above, but the header you're looking to will vary. Choose the condition to match by looking in the full headers of an email you receive. Here are some examples:
# Match subject lines with "turnips" if ( /^Subject:.*turnips.*/ ) # Match emails from Tom if ( /^From:tom@jazzytom.hu/ ) # Match emails to a mailing list # (may not always work!) if ( /^List-Post:.*fc-uk-discuss.*/ )
The filter actions are really obvious: pick a folder you want to send the email to, and define it!
# Send to the folder 'Trash', which is a subfolder of the inbox
to: Maildir/.INBOX.Trash
# Send to the folder 'tom', which is a subfolder of 'storage'
to: Maildir/.storage.tom
Here are some ideas to help you understand and get you started!
# Trashing test messages
if (/^Subject:test$/)
{
exception {
to Maildir/.Trash/
}
}
# Personal
if ( /^From:.*(tom|ed|ali|sarah).*/ )
{
exception {
to Maildir/.Personal/
}
}
# For the fc-uk-discuss mailing list
if (/^List-Post:.*fc-uk-discuss.*/ )
{
exception {
to $DEFAULT/.lists.fc-uk/
}
}