Next: GNU Extensions, Previous: Tests, Up: Sieve Language
The gnu libsieve supports the following default actions:
Among them the first three actions do not need to be explicitly required
by a require statement, while the others do.
These actions are described in detail below.
The
stopaction ends all processing. If no actions have been executed, then thekeepaction is taken.
The effect of this action is to preserve the current message in the mailbox. This action is executed if no other action has been executed.
Discardsilently throws away the current message. No notification is returned to the sender, the message is deleted from the mailbox.Example:
if header :contains ["from"] ["idiot@example.edu"] { discard; }
Required arguments:
- folder
- A string representing the folder name
The
fileintoaction delivers the message into the specified folder.
The optional
rejectaction refuses delivery of a message by sending back a message delivery notification to the sender. It resends the message to the sender, wrapping it in a “reject” form, noting that it was rejected by the recipient. The required argument reason is a string specifying the reason for rejecting the message.Example:
If the message contained
Date: Tue, 1 Apr 1997 09:06:31 -0800 (PST) From: coyote@desert.example.org To: roadrunner@acme.example.com Subject: I have a present for you I've got some great birdseed over here at my place. Want to buy it?
and the user's script contained:if header :contains "from" "coyote@desert.example.org" { reject "I am not taking mail from you, and I don't want your birdseed, either!"; }then the original sender <coyote@desert.example.org> would receive the following notification:
To: <coyote@desert.example.org> X-Authentication-Warning: roadrunner set sender using -f flag Content-Type: multipart/mixed; boundary=----- =_aaaaaaaaaa0 MIME-Version: 1.0 ----- =_aaaaaaaaaa0 The original message was received at Tue, 1 Apr 1997 09:07:15 -0800 from coyote@desert.example.org. Message was refused by recipient's mail filtering program. Reason given was as follows: I am not taking mail from you, and I don't want your birdseed, either! ----- =_aaaaaaaaaa0 Content-Type: message/delivery-status Reporting-UA: sieve; GNU Mailutils 0.1.3 Arrival-Date: Tue, 1 Apr 1997 09:07:15 -0800 Final-Recipient: RFC822; roadrunner@acme.example.com Action: deleted Disposition: automatic-action/MDN-sent-automatically;deleted Last-Attempt-Date: Tue, 1 Apr 1997 09:07:15 -0800 ----- =_aaaaaaaaaa0 Content-Type: message/rfc822 From: coyote@desert.example.org To: roadrunner@acme.example.com Subject: I have a present for you I've got some great birdseed over here at my place. Want to buy it? ----- =_aaaaaaaaaa0If the reason argument is rather long, the common approach is to use the combination of the
text:and#includekeywords, e.g.:if header :mime :matches "Content-Type" [ "*application/msword;*", "*audio/x-midi*" ] { reject text: #include "nomsword.txt" . ; }
The
redirectaction is used to send the message to another user at a supplied address, as a mail forwarding feature does. This action makes no changes to the message body or existing headers, but it may add new headers. It also modifies the envelope recipient.The
redirectcommand performs an MTA-style “forward” — that is, what you get from a .forward file usingsendmailunder unix. The address on the SMTP envelope is replaced with the one on theredirectcommand and the message is sent back out. Notice, that it differs from the MUA-style forward, which creates a new message with a different sender and message ID, wrapping the old message in a new one.