Scanning incoming email on OS X using Clamav


Obvious enough really - it's a sane expectation that ones' incoming email is automatically scanned for viruses. This HOWTO explains how to configure Clamav and Apple OS X Mail to tag the subject line of infected emails such that you may choose for yourself what to do with them. This work was developed in concert with other posters at the ClamXav forum and originally published at Macgeekery - one hell of a site I must say!



  1. Optionally set up clamd (see my HOWTO here). This step is not a pre-requisite, but is very strongly recommended. Without it, Mail will take significantly longer to check for new email, and will be unresponsive to user input whilst doing so.
  2. Download the Applescript listed above and put it wherever you keep your Applescripts.
  3. Double-click it to open it up in Script Editor.
  4. If you have chosen not to install clamd at step 1, search for clamdscan and replace it with clamscan.
  5. Click the 'Compile' button. If you get no errors, save the script as 'execute-only'.
  6. Switch to Mail and go into Preferences. In the Rules pane, add a rule that, for all mail, runs an Applescript. Navigate to your newly-saved .scpt file using the 'Choose...' button.
  7. Drag this rule to the top of the list so that it is processed first and close Preferences.
  8. Test it. To do this, send yourself an email with the eicar test file attached to it. If that mail has "[**VIRUS** - ClamAV]" preprended to it's subject line then you're all done.