View Single Post
Old 23 Dec 2018, 07:02 AM   #2
n5bb
Intergalactic Postmaster
 
Join Date: May 2004
Location: Irving, Texas
Posts: 8,929
Arrow Folder targeting

The sieve language provides an implicit “keep” which by default saves a message into the initial target folder. Fastmail allows the target folder when sieve execution starts to be set in three ways:
  1. Plus+addressing: Instead of an incoming message being addressed to user@example.org, the sender addresses it to user+foldername@example.org. If you need to file into a subfolder you must separate the main folder name and subfolder name by a full stop (period) character “.”. So an incoming message might be addressed to user+friends.bookclub.jane@example.org and it will target the Inbox.friends.bookclub.jane folder at your account.
  2. Subdomain addressing: The subdomain portion of the address specifies the Fastmail user account and the portion of the address before @ specifies an automatically created plus+address. So friends.bookclub.jane@user.example.org creates a delivery address of user+friends.bookclub.jane@example.org which targets delivery to the Inbox.friends.bookclub.jane folder at your account.
  3. Alias targeting: Messages sent to your main account (login) address target your Inbox unless subdomain or plus+addressing is used. But in the Aliases setup screen you can specify a plus+address as the target for an alias. So you could create the alias jane@example.org with the target user+friends.bookclub@example.org and messages sent to the alias jane@example.org will be targeted for delivery to the Inbox.friends.bookclub.jane folder using subdomain addressing as described above. If the alias target includes a wildcard * such as user+*@example.org, the portion of the address left of the @ is used in the plus+address, so a message to jane@example.org will be resolved to user+jane@example.org to the Inbox.jane folder.
The X-Resolved-To header is determined as described above, and this determines the target folder when your sieve scripts starts.
  • If there is no discard, fileinto, or redirect command actually executed by the time the sieve script ends, the message is delivered into the target folder.
  • If a discard command is executed, the message is permanently discarded. It will not be in your Trash folder.
  • If a fileinto command (without a :copy tag) is executed before the sieve script ends, the final fileinto target replaces the default target folder described above. The implicit “keep” is ignored.
  • If a redirect (without :copy tag) command is executed before the sieve script ends, the message is redirected and sent to the address in that command. The implicit “keep” is ignored.
  • If a fileinto or redirect command is executed with a :copy tag, the implicit “keep” is not ignored. The message will be filed into the target folder described above and the message will be filed or redirected.
The “:copy” tag described above is part of the following addendum to the sieve standard:
Copying without side effects
https://tools.ietf.org/html/rfc3894

Your first sieve fragment is not needed in most cases if you are not using subdomain or plus+addressing. The default action is to “keep” without any action on your part. The sieve fragment will have two effects:
  • Any folder target set by plus+addressing, subdomain addressing, or alias targeting will be ignored. The message is forced to be saved in your Inbox folder.
  • Discard commands in the script are ignored. As long as the statement which includes the explicit “keep” is executed before the sieve script terminates, the message will be saved in your Inbox folder and discards will be ignored.
Your second sieve fragment will cause the implicit “keep” action to be ignored (unless there is an explicit “keep” commend or fileinto or redirect with “:copy” tag executed), and the message will not be saved by default into the target folder as described above.

If you want to file a copy of a message in a certain folder and also let it be automatically filed into the target folder (by default Inbox), all you need to do is include the “:copy” tag as described in RFC3894. For example, this code will file a message which matches he test condition into both the Inbox and X folders:
Code:
If ...test condition... {
   fileinto :copy “INBOX.X”;
}
Bill
n5bb is offline   Reply With Quote