This is an old revision of the document!
Table of Contents
Filtering with Sieve
Sender
Storing in different folder upon (envelope) sender:
require ["fileinto", "envelope"]; if envelope "from" "user1@rigacci.org" { fileinto "FromUser1"; }
Recipient
Storing in different folder upon destination address:
require ["fileinto"]; if address :is "to" "MyAlias1@rigacci.org" { fileinto "ToAlias1"; }
Forward and keep a local copy
The redirect built-in action can be modified by the :copy tag (which is a built-in extension, but it must enabled using the require statement). The :copy
means that the message is not completed by the redirect
action; eventually the keep
action will be finally executed.
require ["copy"]; # Forward the messages unconditionally and continue processing. redirect :copy "niccolo@texnet.it";
Forward with From rewrite (to pass SPF check)
Rewrite the From header before forwarding, to ensure to pass the SPF checks at destination. This does not work, beacuse it rewrites only the From header, not the envelope sender (which is generally reported as Return-Path).
require ["editheader"]; deleteheader "from"; addheader "From" "user1@forwarding.domain"; redirect "user2@forward.destination.domain";
NOTICE: To use the editheader plugin you must enable it into Dovecot configuration file (in Debian edit /etc/dovecot/conf.d/90-sieve.conf), adding it into the sieve_extensions list:
plugin { ... sieve_extensions = +vnd.dovecot.filter +editheader ... }
Pipe a message to an external program
require ["fileinto", "vnd.dovecot.execute"]; # Specially crafted messages are piped to an SMS gateway. if allof ( anyof ( address :is "from" "user1@rigacci.org", address :is "from" "user2@rigacci.org"), header :contains "Subject" "SMS" ) { execute :pipe "sms-gateway"; }
The execute command is not considered a final action (which “consumes” the message), so the keep action is eventually taken.