Next Previous Contents

13. Filters, actions and templates

Sylpheed offers three powerfull tools to help you automatically and efficently manage you mails. These tools are:

13.1 Filters

Written by Nick Selby (

Sylpheed provides powerful filters to allow users to automatically pre-sort incoming mail based on a set of rules that the user defines. As a most simple example, let's say you work at the Acme Grommet Company, and you want all e-mail from your co-workers to be placed in one mailbox. To accomplish this, you would set up a filter that would place all mail whose "From" header includes the phrase "" into a specific mailbox.

Sylpheed allows you much more control than just that simple setup; you may create filters based on several variables, including an "If this AND that" or "If the message contains this OR does NOT contain that" etc. It's very cool.

Finding The Filter Setting Dialog

The filter settings dialog is located in the Configuration menu, under the title "Filter Setting" or from the Tools menu, under in the Create filter rules sub menu. You may also use establish a keyboard shortcut (see Keyboard Shortcuts).

Setting Up Filters

Operator(s) and Processing instructions combine to create a Filter Rule.

* Operators The dialog's first setting option establishes the Operator, the variable that will tell the filter what specific text to look for to trigger a filter. Each Filter Rule may have up to two operator sets.

Each Operator variable contains three sections: Header, Keyword and Predicate.

Header is a drop-down box which defines in which message header Sylpheed's filter will search. Choices range from Subject to X-Mailer.

Keyword is a a text box in which you may enter the text for which the filter will search.

Predicate allows you to choose to filter based on whether the operator contains, or does not contain, the text you enter in the Keyword field.

Example: Create an Operator in which the X-Mailer field of an incoming message contains the word 'Eudora'.

The second Operator setting, which is set identically to the first, also allows the user to select an AND/OR setting declaring the relationship between the two operators.

Example: Create an Operator set which will process mail with a From header of AND a subject of "2001 Spring Grommet Collection"

Message Processing

Once you've established the Operator(s) that will define which messages will be processed, it's time to tell Sylpheed what to do with messages that match the operator(s). You may choose between two radio button-selected settings: Destination and Don't Receive.

Selecting Destinations will enable you to route the mail into a mailbox which you specify.

Selecting Don't Receive will instruct Sylpheed to not download messages with that operator. Note that with Don't Receive, Sylpheed merely leaves the message on your mailserver - it does not delete it.

To specify a mailbox to which you want the message transfered, click on the radio button to the left of the word Destination in the dialog. (Currently, in order to specify a mailbox you must have created that mailbox prior to activating the Filter Setting dialog.) Clicking the Select button will open a pop-up window containing all mail folders currently active in your copy of Sylpheed. Select the mailbox you wish by either

To specify that the message not be retrieved, and left on your mail server, click the radio button to the left of the words Don't Receive.

Filter Registration

Now that you have set the Operator and the Processing Rule, all that's left to do is tell Sylpheed to save the entire Filter Rule. If you skip this step, the filter won't work.

The Register Rules configuration has three options: Register, Substitute and Delete.

Example of Registering A Filter Rule: Create a Filter Rule that moves all mail with the subject of "Sylpheed Manual" into the (previously created) mail folder "Sylpheed Manual Mail".

Example of Substituting A Filter Rule: Modify a previously created Filter Rule that moves all mail with the subject of "Sylpheed Manual" to sort mail not to the mail folder "Sylpheed Manual Mail" but rather the mail folder "Sylpheed Questions"

Example of Deleting a Filter Rule: Remove the previously created Filter Rule which refers to Subject:Sylpheed Questions.

Registered Rule Order

One caveat about all this: the order in which Filter Rules are created could adversely affect your intended message sorting, and one needs to consider this when creating or updating Filter Rules.

For example, a Filter Rule saying, "Move anything containing 'ABC' to Mailbox X" listed above another Filter Rule saying "Move anything containing 'ABCDEF' to Mailbox Y" will cause the latter of these filters not to process.

Think about the way Sylpheed goes down its list: first, it would say.. "Hmm, any messages with ABC? Ah, there's one! Move it". Then it would think, "Okay, any messages with ABCDEF?" To which the answer would be "no" - that ABCDEF was already filtered because it contained "ABC".


In order to avoid this, you must ensure that the more complex Filter Rule is processed first, by placing it higher than a similar, conflicting Filter Rule.

To move a Registered Rule higher or lower within the Registered Rule box, select the rule you would like to move, and click on the Up or Down buttons. This will "move" the rule up or down, above or below a potentially conflicting Filter Rule.

13.2 How to Filter Messages

Filtering messages can be done in several ways:

Please note that, at time of writing, Sylpheed does -NOT YET- has filtering of IMAP messages enabled.

13.3 Filtering mail with Procmail

If you feel that Sylpheed has not enough options to perform filtering for you, then you can look at Sylpheed Claws which has more options for filtering. You can find the Claws version (the cutting edge, experimental version of Sylpheed)

Another option, if you do not want to work with an experimental version of Sylpheed, is Procmail. Procmail is a powerful mail filtering program that is triggered from the Mail Transport Agent (i.e. Sendmail, Postfix, Qmail). Procmail is called by default from these programs after receiving e-mail.

The trick to procmail is to tell it that mail has to be filtered into MH mail folders. This is not difficult though.

Normally procmail moves mail into MBOX format, this is one large file containing all mails in a folder. MH uses separate files for each e-mail. All you need to do is point the destination of a procmail rule to <destination folder>/. It is the "slash dot" that does the trick.

13.4 Actions

The following section is a copy of Melvin's page.

The "actions" feature is a convenient way for the user to launch external commands to process a complete message file including headers and body or just one of its parts. It allows also the use of an external command to filter the whole text or just a selected part in the message window or in the compose window. This is a generic tool that allows to do any uncommon actions on the messages, and thus extends the possibilities of Sylpheed. For example, Sylpheed does not include the rot13 cyphering algorithm popular in some newsgroups. It does not support natively armored encryption or clear signing. It does not support uuencoded messages. As all these features can be handled by external programs, the actions provide a convenient way to use them from the menu bar.


To create a new action, go to the Configuration menu, select the Actions... entry. The Actions setting dialog offers to enter the Menu name that will trigger the command. The created menu will be found in the Tools -> Actions submenu. By inserting a slash / in the menu name, you create a submenu.

The command is entered in the Command line entry. Note that Sylpheed stores every single email in a separate file. This allows to use the following syntax for the command:

Note: It is not possible to use actions containing %f, %F or %p from the compose window.

When a command is run, and unless it is run asynchronously, Sylpheed will be insensitive to any interaction and it will wait for the command to finish. If the command takes too long (5 seconds), it will popup a dialog window allowing to stop it. This dialog will also be displayed as soon as the command has some output: error messages or even its standard output when the command is not a "pipe-out" command. When multiple commands are being run, they are run in parallel and each command output is separated from the outputs of the others.


Here are some examples that are listed in the same syntax as used for storing the actions list. You can copy and past the definition in your  /.sylpheed/actionsrc file (exit Sylpheed before). The syntax is very simple: one line per action, each action contains the menu name and the command line separated by a colon and a space ": ". Alternatively, you can use Configuration -> Actions... and for each example enter a menu name and copy&paste the text after the colon and space ": " in the command definition.

Decoding uuencoded messagesUUdeview: xdeview %F&xdeview comes with uudeview. If an encoded file is splitin multiple messages, just select them all and run the command.
Display uuencoded imageDisplay uuencoded: uudec %f&Displays uuencoded files. The uudec script is to be found here.
rot13 cypheringRot13: |tr a-zA-Z n-za-mN-ZA-M|This will apply the rot13 cyphering algorithm to the (selected)text in the message/compose view.
Save MS TNEF partsSave TNEF part: xterm -e tnef-claws %pSelect the TNEF message part then use this action to extractthe attachment.
Alter messagesEdit message: gvim -f %FAllows to edit any received message. Can be used to removeunneeded message parts etc.
Pretty formatPar: |par 72Tbgjqw74bEe B=._A_a 72bgi|par is a utility that can pretty format any text. It does avery good job in indenting quoted messages, and justify text.Used when composing a message
BrowsePart/Dillo: dillo %p&Browse the selected message part in Dillo.
Clear SignGnuPG/Clear Sign: |gpg-sign-syl|Clear sign a message. The gpg-sign-syl script is responsiblefor asking the passphrase and for running gnupg. Make surethat you wrap your message correctly before signing, and thatthe resultant text will not be wrapped when sent (by disabling'wrap on send')
Verify Clear SignedGnuPG/Verify: |gpg --no-tty --verifyVerify clear signed messages. The result is displayed in theactions output dialog.
Encrypt ASCII ArmoredGnuPG/Encrypt: | gpg-enc-syl|Encrypt message to ASCII armored. The recipient will be askedin a xterm.
Decrypt ASCII ArmoredGnuPG/Decrypt: *gpg --no-tty --command-fd 0 --passphrase-fd 0 --decrypt %f|Decrypt ASCII armored messages. The passphrase is to be enteredin the opened action's input dialog.
Receive key from serverGnuPG/Receive Selected Key: |gpg --recv-key `cat`Select a key ID in the message view then call this action toimport it from a key server. GnuPG option file must contain areference to a keyserver. (Suggested by Bob Forsman)
Import key from mailGnuPG/Import Key From Mail: gpg --import %pSelect the message part where the public key is then importit with this action.
Insert public key in messageGnuPG/Insert My Public Key: gpg --export -a MYKEYID>Insert your public key in the message your are composing.Replace MYKEYID with your key id. Needs 0.8.6claws66 or newer.
Reporting SPAMReport as SPAM: spamassassin -r > %fUse spamassassin to report mail as spam. Redirection (>)is possible only with version 0.7.7.
Check spellingCheck spelling: |T=`mktemp $HOME/.sXXXXXX`; cat - > $T;xterm -e ispell $T;cat $T;rm $T|Open a terminal and check the spelling with ispell
Google for message idGoogle Msg ID: |google msgid.plSearch the web for the selected message ID. Needs thegoogle script.

The gpg-enc-syl script is to be found here (gpg-enc-syl). It calls gpg with the --yes command line option that you may want to remove it. See gpg manual page for info.

The gpg-sign-syl script is to be found here (gpg-sign-syl). It needs the ssh-askpass utility found in OpenSSH. It can be replaced by any X11 tool that asks some (hidden) text which is then sent to standard output. Another version that uses an xterm is to be found here (gpg-sign-syl-xterm).

The uudec script is to be found here (uudec). It needs uudecode and ImageMagick's display. The latter can be replaced by any image viewer that can get input from standard input. The script could also be modified to use temporary files instead of standard input.

The script is to be found here ( Example and script by Thorsten Maerz. Edit the script to change the browser (default is mozilla).

The tnef-claws bash script was written by Shawn Lamson and is to be found here. The script is well commented. You need to have the tnef package already installed.

13.5 Templates

With Sylpheed you can define mail templates to use when replying to messages. A template can contain raw text (that will be inserted in the composed mail without any change), and placeholders that are replaced at composition time by the actual value of the selected fields from the original message.

A typical use of the template could be to define the legal notice to be appended to your messages (the usual notice that contains a text like: "here are my own words and not those of my company, my boss is not liable for them, bla, bla, bla").

To define a new template, in the Configuration menu select the Templates entry and fill the form:

The name parameter is used to identify each template, this name will then appear in the Tools/Templates menu in the composition window. The content of the To field will be appended to the original content of the corresponding field in the message you are composing. The content of the Subject field will replace the orignal subject of the message you are composing.

In the upper pane, type in the text you want to put in the template, use the Symbols button to open a help window that contains the description of all the placeholders you can use in a template (there is one for the sender, one for the date, one for the message ID, ...), then use the Register button to validate the template. If you do not register the template, when leaving the form the template will be canceled. To modify an existing template, select it in the lower pane, modify its text, then use the Substitute button. As you may guess, the Delete button removes the selected template. Finally validate your changes with the OK button. If you use the Cancel button, the form is closed and your changes are lost (deleted templates are back, added templates are lost).

To use a template, open the composition window and select the template from the Tools/Templates menu. You can then choose to insert the template into your message or to completely replace the text of the message by the template. This only affects the body of the message. If you choose to insert the template, its text will be inserted at the cursor location.

The placeholders are taken from the source message when replying, so they have no meaning when composing a new message.

Next Previous Contents