https://www.claws-mail.org/faq/api.php?action=feedcontributions&user=Joe-generic&feedformat=atom Claws Mail FAQ - User contributions [en] 2024-03-29T00:56:17Z User contributions MediaWiki 1.35.7 https://www.claws-mail.org/faq/index.php?title=Filtering_and_Processing_of_Messages&diff=2154 Filtering and Processing of Messages 2010-08-24T18:45:39Z <p>Joe-generic: /* What is the difference between Filtering, Folder Processing, Pre/Post-processing? */</p> <hr /> <div>&lt;div id=age&gt;<br /> === What type of value do the &quot;age ...&quot; match types in the filtering configuration expect? ===<br /> <br /> You simply have to add the value in days. If you want for example to select messages older than a month, enter 30 or 31.<br /> <br /> Example of a folder processing rule of the &quot;mailbox/claws-mail/&quot; Folder, that move messages older that 60 days to an archive folder:<br /> &lt;pre&gt;<br /> age_greater 60 move &quot;#mh/mailbox/claws-mail/archive&quot;<br /> &lt;/pre&gt;<br /> <br /> '''Note:''' Age checks are done against the 'Date'-header in the mail. So if the sender has misconfigured his computer and sends mails with a wrong date, the rule could move mails instantly if the date is more then 60 days in the past or never when it is in the future.<br /> &lt;/div&gt;<br /> === Can I filter messages based on Content-Type of attachments, for example &quot;application/x-msdownload&quot;? ===<br /> <br /> Yes. Select Match Type 'Body part' and enter the Value &lt;code&gt;Content-Type: application/x-msdownload&lt;/code&gt;.<br /> <br /> Please note that application/octet-stream is also a potential infected content (.pif for instance).<br /> You can also use a more generic case-unsensitive regexp matching rule against the 'Body part' like the following one:&lt;br&gt;<br /> &lt;pre&gt;<br /> Content\-Type: ~[[a-z0-9_/-]]+; name=&quot;~[[^\.]]+\.(bat|pif|cmd|vbs|vba|scr|lnk|com|exe|java|asp|cgi)&quot;<br /> &lt;/pre&gt;<br /> <br /> '''Note:''' This will also match text inside the message and not only the Content-Type, so be aware of messages discussing the structure of MIME-Mails.<br /> <br /> === What is the difference between Filtering, Folder Processing, Pre/Post-processing? ===<br /> <br /> Filtering rules are global. Messages received on an Account can be filtered in 2 ways, automatically or manually. To have the messages filtered automatically the option 'Filter messages on receiving' must be checked on the 'Receive' tab in the Account Preferences. Manual filtering can be performed by using '/Tools/Filter all messages in folder' or '/Tools/Filter selected messages'.<br /> <br /> Folder Processing rules apply only to the messages contained in that particular folder. A folder's Processing rules are applied upon entering that folder, or on program startup if 'Process at startup' is checked in a folder's Properties, or on demand by using 'Run processing rules' from the folder's context menu.<br /> <br /> Pre and post-processing rules are global rules which are executed before and after the folder processing rules, respectively.<br /> In other words: Whenever you select a folder, first pre-processing rules are applied, then folder specific processing rules and lastly post-processing rules. See [[Filtering_and_Processing_of_Messages#age|'age'-question]] for an example.<br /> <br /> === Can a filter modify the contents of a message? ===<br /> <br /> None of the built-in filters modify the contents of a message, but you can use the 'test' filter to run a command that can modify the contents of a message. See the next question for an example.<br /> <br /> === How do I configure a filter for running SpamAssassin? ===<br /> <br /> If you want to use SpamAssassin directly, instead of using the plugin, you can get the SpamAssassin headers added to each message, and/or tag the subject line of spam messages. First, you have to set up SpamAssassin correctly, which is beyond the scope of this FAQ. This example uses the spamc/spamd client server model, but it could easily be adapted for calling SpamAssassin directly. First, save this script somewhere in your PATH (eg $HOME/bin/sc-spamc).<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> #<br /> # sc-spamc : a script for using SpamAssassin header modification / subject<br /> # tagging vi Claws Mail filtering actions.<br /> #<br /> # Author: Robert Story<br /> # Send questions or comments to the claws-mail-users mailing list<br /> #<br /> # Based on a simpler script posted to the claws-mail-users mailing list<br /> # by Richard A Downing.<br /> #<br /> # Should return the return code from spamc (1=spam, 0=nospam/error)<br /> #<br /> <br /> die()<br /> {<br /> : error &quot;$@&quot;<br /> : exit 0<br /> }<br /> <br /> FILE=$*<br /> TEMP=sc-spamc.$$<br /> <br /> #<br /> # call spamc, redirect output to temporary file, and save return value<br /> #<br /> /usr/bin/spamc -E -t 30 &lt; &quot;$FILE&quot; &gt; &quot;$TEMP&quot;<br /> RC=$?<br /> <br /> #<br /> # make sure temp file exists before we replace original message<br /> #<br /> if ! test -s &quot;$TEMP&quot; ; then<br /> : die &quot;spamc result file doesn't exist or is 0 bytes&quot;<br /> fi<br /> <br /> #<br /> # backup original<br /> #<br /> mv &quot;$FILE&quot; &quot;$FILE.bak&quot;<br /> if $? -ne 0; then<br /> : die &quot;'mv $@' failed!&quot;<br /> fi<br /> <br /> #<br /> # rename filtered file<br /> #<br /> mv &quot;$TEMP&quot; &quot;$FILE&quot;<br /> if ! 0 = $?; then<br /> : mv &quot;$FILE.bak&quot; &quot;$FILE&quot;<br /> : die &quot;spam result rename failed, restoring backup&quot;<br /> else<br /> : rm &quot;$FILE.bak&quot;<br /> fi<br /> <br /> #<br /> # return spamc exit code<br /> #<br /> exit $RC<br /> &lt;/pre&gt;<br /> Now, set up a Filtering rule (test &quot;!(sc-spamc %F)&quot;), with an action for dealing with spam (eg color it, move it to a folder, etc).<br /> <br /> === How do I add a filter for SPF checking? ===<br /> <br /> To check if the sender IP address matches the SPF record you can download the script sylpheed-spf.pl from http://www.willamowius.de/claws-spf.html and add a filter with the following condition and move matching mails to your spam folder.<br /> <br /> &lt;pre&gt;<br /> test &quot;!(sylpheed-spf.pl -c &lt;%F)&quot;<br /> &lt;/pre&gt;<br /> <br /> === My ISP adds headers that identify spam and viruses. How do I filter on a custom header? ===<br /> <br /> You can filter on a custom header. The drop-down list of headers defaults to the commonly used headers, but you can edit the list and add new entries. Create a filter in the normal way and select &quot;Header&quot; as the condition. Simply start typing in the list box to edit or add a header.</div> Joe-generic