Software optimize

Create Claws Mail actions to launch external commands for advanced email processing

Learn how Claws Mail's Actions tool extends the cross-platform email client's feature set. Jack Wallen provides sample external commands to help you get started with Actions.

Claws Mail is one of the most powerful email clients available. There are so many features and tweaks with the software that you could spend hours discovering new methods to make Claws Mail do things other email clients cannot.

The Claws Mail advanced tool Actions is a way for the user to easily launch external commands to process a complete message file (including headers and body), as well as filter part of or the entire text in the message window or the compose window.

These are some of the things you can do with Actions:

  • Apply cyphering algorithms
  • Display uuencoded files
  • Open uuencoded files with an external program (such as LibreOffice)
  • Save attachments from multiple emails
  • Save MSTNEF parts of messages
  • Edit messages
  • "Pretty" format text
  • Browse the selected message text
  • Receive GPG keys
  • Display encryption keys within message
  • Spell check
  • Search Google for selected text

Claws Mail is available with a simple installer for Linux and Windows. For Mac, you need to follow these steps for building it.

Creating and configuring an action

It's simple to create an action, as long as you understand the necessary switches. These switches and fields are used in conjunction with the commands:

  • %f - denotes the file name of the selected message.
  • %F - denotes the list of the file names of the selected message.
  • %p - denotes the current selected message part of a multi-part message.

Every external command will have its own built-in switches. You must fully understand the command structure before you can use an external command for an Action. Since so many external commands can be used, I am offering several examples to get you started.

Let's say a lot of users are sending emails with their GPG keys attached. Instead of saving the key and importing the key from the command line, you could create an action that will allow you to right-click the email and select an action. Here's how to create this action.

To start the process, you need to know the command you want to use. For our first action, we will import a GPG key; for this to work, GnuPG must be installed. The command we will use for this action is gpg --import %p. The --import switch is from the gpg command and tells gpg to import the key (which is defined using the %p field). This is where you add the action:

  1. Open Claws Mail.
  2. Click Configuration | Actions.
  3. In the new window, enter the information for the action (Figure A):
    • Menu Name: The name that will appear in the Actions menu.
    • Command: The command used for the Action.
    • Shell Command: If this is a command, select this option.
    • Filter Action: If this Action is for filtering, select this option.
  4. Click the Add button.
  5. Click the OK button.

Figure A

For more information about fields, click the Information button. Also, you can also move your actions up and down the Current Actions list so the ones you use most are at the top.
When you create an action, it will appear in the Tools | Actions view (Figure B). If you select an email and then click your new action, the action will take place (in this case, the importing of the gpg key). Figure B

Our GPG import action listed.

Now that you know how to create the actions, here are more samples you can use.

Report spam: If you have SpamAssassin installed, you can report an email is spam by adding this command as an action:
spamassassin -r < %f
Search Google: Highlight a section of text in the email and then search Google for the string. For this to work, download the google_search.pl file and place it in /usr/local/bin/.
google_search.pl
Save Attachments: You can select one or more emails and save any or all of the attachments into your home folder. This action requires the mpack package.
munpack -C ~ -- %F

Creating Filter Actions

Follow these steps to create Filter Actions:

  1. Go to Configuration | Actions and give the filter a name.
  2. Select Filter Action.
  3. Click the Edit Filter Action.
  4. In the new window, enter the necessary information (Figure C).
  5. Click the Add button and then click the OK button.

Figure C

Depending upon the Action selected, the Destination section will differ.

You can create these types of Filter Actions:

  • Move
  • Copy
  • Delete
  • Hide
  • Message Flags
  • Execute
  • Color Label
  • Resend
  • Score
  • Tags
  • Threads
  • Add to Address Book
  • Stop Filter

Give Claws Mail Actions a try -- I bet you'll be astonished by how much you can do with the email client's powerful tool.

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

2 comments
colin
colin

Hi, Thanks for that article. I just wanted to point out a few things that you use as actions examples, but are also Claws features: - "Import GPG key" can be done by selecting the signature part of a signed email, when the key isn't in the keyring. - "Report spam", or rather "Learn as spam" can be done with all our spam plugins (Spamassassin, Bogofilter and BSFilter). There's also a SpamReport plugin to report spam to some entities like SpamCop. - "Save MSTNEF parts of messages" - TNEF format is handled by the TNEF Parse plugin. HTH ! :-)

office2254
office2254

Thank you so much, this is simply amazing!!