sieve and imapflags?

Mike Eggleston mikeegg1 at mac.com
Wed Aug 29 16:34:13 EDT 2007


On Wed, 29 Aug 2007, Mike Eggleston might have said:

> I'm still testing and still trying to get a response from vacation.
> I came across that sieve had the functionality for modifying the
> imap flags. For junk messages messages tagged as spam I want the
> message file and the \\seen and \\deleted flags set. My script is:
> 
> -------------------------------------- sieve script
> # load the necessary components
> # fileinto is for filtering
> # vacation is ... well ... just that
> 
> require ["fileinto", "vacation", "imapflags"];
> 
> # save a copy of inbound messages
> fileinto "INBOX.backup";
> 
> # main filtering rules
> if header :contains "Subject" "testing vacation" {
>   vacation :days 4 "I'm testing, ok?!";
>   fileinto "INBOX.howard";
> } elsif address :contains ["to","from","cc","bcc"] ["@mac.com","admin5@$domain.com"] {
>   vacation :days 4 "I'm testing, ok?! (2)";
> } elsif header :contains "Subject" "*** SPAM ***" {
>   fileinto "INBOX.spam";
>   setflag ["\\seen", "\\deleted"];
> } elsif header :contains "Subject" "*** VIRUS" {
>   fileinto "INBOX.spam";
> } elsif header :contains "Subject" "/usr/bin/fetchmail" {
>   fileinto "INBOX.spam";
>   setflag ["\\seen", "\\deleted"];
> } elsif header :contains "Subject" "[ppml]" {
>   fileinto "INBOX.arin";
>   setflag "\\seen";
> } elsif address :contains ["to","from","cc","bcc"] "hobbit@$domain.com" {
>   fileinto "INBOX.hobbit";
>   setflag ["\\seen", "\\deleted"];
> } elsif address :contains ["to","from","cc","bcc"] "monit@$domain.com" {
>   fileinto "INBOX.hobbit";
>   setflag ["\\seen", "\\deleted"];
> } elsif address :contains ["to","from","cc","bcc"] "ipcop@$domain.com" {
>   fileinto "INBOX.hobbit";
>   setflag ["\\seen", "\\deleted"];
> } elsif address :contains ["to","from","cc","bcc"] "Mail Delivery Subsystem" {
>   fileinto "INBOX.messages";
>   setflag ["\\seen", "\\deleted"];
> } elsif address :contains ["to","from","cc","bcc"] "Courier mail server" {
>   fileinto "INBOX.messages";
>   setflag ["\\seen", "\\deleted"];
> } elsif header :contains "Subject" "NOTICE: mail delivery status" {
>   fileinto "INBOX.messages";
>   setflag ["\\seen", "\\deleted"];
> } elsif header :contains "Subject" "Returned mail: see transcript for details" {
>   fileinto "INBOX.messages";
>   setflag ["\\seen", "\\deleted"];
> } elsif header :contains "Subject" "Postmaster notify: see transcript for details" {
>   fileinto "INBOX.messages";
>   setflag ["\\seen", "\\deleted"];
> } else {
>   fileinto "INBOX";
> }
> -------------------------------------- sieve script
> 
> I'm testing the lines that are 'setflag' or 'addflag'. I've
> changed the 'addflag' lines to 'setflag', but neither line
> seems to work. I've also tried 'fileinto :flags "\\seen" INBOX.spam',
> but this didn't work either.
> 
> See anything wrong?
> 
> fedora core 5
> cyrus imap 2.3.1
> 

Well, part of the problem is 'setflag' must come before 'fileinot'. Now
the flags are being set right.


More information about the Info-cyrus mailing list