Sieve script
require ["fileinto"]; require ["envelope"]; require ["regex"]; require ["variables"]; require ["mailbox"]; require ["environment"]; /* check for mail addressed to Bacula originating from one of our domains or localhost */ if envelope :regex :comparator "i;ascii-casemap" "To" "^(bacula|bacula-sysman|bacula-operator)@([^\.].*)\.(mydomain)\.(com|net)$" { /* mail is addressed to one of our servers and is Bacula related */ set "baculaserver" "${2}"; } elsif envelope :regex :comparator "i;ascii-casemap" "To" "^(bacula|bacula-sysman|bacula-operator)@localhost" { /* mail is addressed to localhost and is Bacula related */ /* * replace hardcoded servername below if needed */ set "thishost" "ourserver"; if environment :matches "host" "*" { #set "hostname" "${1}"; /* fqdn */ /* (^([^\.]+)\.(.+)) ----> $0=fqdn $1=hostname $2=domain */ if environment :regex "host" "([^\\.]+)(\\.[^\\.]+)*" { set "hostname" "${1}"; } #set "hostname" "${thishost}"; } else { set "hostname" "${thishost}"; } set "baculaserver" "${hostname}"; } else { keep; stop; } /* if it was not a Bacula related mail by now this sieve script should have been ended whilst * keeping the emailmessage to be processed otherwise */ if header :contains ["subject"] "Error" { /* mail seems to be an error report: file in submap of reports on errors for this specific server */ fileinto :create "PUBLIC/bacula/${baculaserver}/error"; stop; } elsif header :contains ["subject"] "Warning" { /* mail seems to contain a warning : file in submap of reports on warnings for this specific server */ fileinto :create "PUBLIC/bacula/${baculaserver}/warning"; stop; } elsif header :contains ["subject"] "Intervention Needed" { /* mail seems to contain a warning : file in submap of reports on warnings for this specific server */ fileinto :create "PUBLIC/bacula/${baculaserver}/warning"; stop; } elsif header :contains ["subject"] "Verify Differences" { /* mail seems to contain a warning : file in submap of reports on warnings for this specific server */ fileinto :create "PUBLIC/bacula/${baculaserver}/warning"; stop; } elsif header :contains ["subject"] "Canceled" { /* mail seems to contain a warning : file in submap of reports on warnings for this specific server */ fileinto :create "PUBLIC/bacula/${baculaserver}/warning"; stop; } /* elsif header :contains ["subject"] "Bacula daemon message" { */ /* mail seems to contain a warning : file in submap of reports on warnings for this specific server */ /* fileinto :create "PUBLIC/bacula/${baculaserver}/warning"; stop; } */ elsif header :contains ["subject"] "OK" { /* mail seems to report a successful operation : file in submap of reports on successes for this specific server */ fileinto :create "PUBLIC/bacula/${baculaserver}/ok"; stop; } else { /* mail is from bacula but is unidentified (should not happen) : file in mainmap for this specific server */ fileinto :create "PUBLIC/bacula/${baculaserver}"; stop; }