View Single Post
Old 8 Oct 2017, 07:38 AM   #21
n5bb
Intergalactic Postmaster
 
Join Date: May 2004
Location: Irving, Texas
Posts: 8,926
Arrow Multiple alias targets allows message to be both bounced and kept

As I suspected, you can use alias targeting to both reject ("bounce") certain messages and keep those messaged in your account. Here is how to do this:
  • You must receive these messages at an alias address. This could be at your private domain or a Fastmail domain. Go to the Settings>Aliases address you will use and add a second target Deliver to address with the addition of +reject before the @. For example, if your main account address was jcitizen@fastmail.com, you would use two target Deliver to addresses for that alias as follows (assuming you want normal delivery to Inbox):
    • jcitizen@fastmail.com
    • jcitizen+reject@fastmail.com
  • Then add the following in the first block of custom Sieve script:
    Code:
    if allof (
      header :contains ["From", "X-Mail-from", "Return-Path"] "xxxx.da.gov",
      header :contains ["X-Resolved-to"] ["jcitizen+reject@fastmail.com"] 
    ) {
      reject "Please don't use this address!";
      stop;
    }
    elsif header :contains ["X-Resolved-to"] ["jcitizen+reject@fastmail.com"] {
      discard;
      stop;
    }
  • When a message from the gov address is received, the sender will receive a reject message as follows:
    • From: Mail Sieve Subsystem <postmaster@messagingengine.com>
    • Subject: Automatically rejected mail
    • Body: Your message was automatically rejected by Sieve, a mail filtering language.

      The following reason was given:
      Please don't use this address!
    • Two attachments are included. One is the original message. The second (named Attachment2) contains the message disposition status. It will be similar to:
      Reporting-UA: sloti22d1t13; Cyrus fastmail-fmjessie45441-15552-git-fastmail-15552/CMU Sieve 3.0
      Original-Recipient: rfc822; <Original destination address>
      Final-Recipient: rfc822; Ys555yY76QL5/Gi34eksvyyKoFA87Wrd33cLPI5cQS 15444113573
      Original-Message-ID: <1507331572.631740.1131244464.466GH196@webmail.messagingengine.com>
      Disposition: automatic-action/MDN-sent-automatically; deleted
    • A copy of the message will be placed in your Inbox..
  • If you receive a normal incoming message to that alias (not from the gov From address), the elseif... clause in the rule will discard the message delivered with +reject. But the normally targeted message will be delivered since my rule will be ignored.
I have tested the Sieve rule I posted above (with a different From and my own alias) and it works correctly. But other Sieve rules (automatic or manual) could interact with this rule, so be sure to test it before trusting it.

Bill
n5bb is offline   Reply With Quote