Beeminder Forum

Sieve script for processing Beeminder Mails

For what it’s worth I’m posting here my WIP selection of sieve scripts for enhancing Beeminder Mails.

I kinda quarter assed this and the first part is working: Adding a flag to all “YOU DERAILED! Now you pay!” mails.

The other part, adding a flag to all bot produced mails from support so I can separate them from all human generated support mails :slight_smile: Well that part doesn’t quite work yet. Seems I have to at least half ass this. Also I just noticed I can write this a bit simpler. Anyway, here goes!

require ["fileinto", "mailbox", "body", "imap4flags", "envelope"];

elsif address :is "to" "your.beeminder.mail@example.com" {
  # This part works:
  if header :matches "subject" ["paying*"] {
    addflag "\\Flagged";
  }
  
  # This part not so much:
  if envelope :is "from" "beeminders.support.mail@example.com" {
    if not header :is "from" "Beeminder Support <beeminders.support.mail@example.com>" {
      # it's a human! The worker bees use "From: Actual Name <beeminders.support.mail@example.com>" in the header
      removeflag ["$MailFlagBit0", "$MailFlagBit1"];
      addflag ["\\Flagged", "$MailFlagBit2"]; # Green in Apple Mail, or blue. Depending on whom you ask.
    }
  }
}