Giter Site home page Giter Site logo

trasherdk / sieve Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thsmi/sieve

0.0 0.0 0.0 17.58 MB

Sieve Script Editor

License: GNU Affero General Public License v3.0

JavaScript 83.41% CSS 0.34% HTML 13.31% Perl 0.82% Shell 0.04% Python 2.08%

sieve's People

Contributors

arvoreen avatar dependabot-preview[bot] avatar dependabot[bot] avatar georgeto avatar irgendwr avatar itagagaki avatar jnbr avatar marclaporte avatar ovari avatar steffen-4s1 avatar tessus avatar thsmi avatar tobiasge avatar

Watchers

 avatar  avatar

sieve's Issues

Ping

Create IMAP folder.

Snippet: How to change a message's subject in a Sieve rule

It seems there is no standardised way to directly prepend or append a string to a message's Subject header, but there is a workaround using the editheaders and variables extensions:

require "editheader";
require "variables";

# Match/select your message as you see fit
if header :contains "List-Id" ["<foo.lists.example.net>"]
{
    # Match the entire subject ...
    if header :matches "Subject" "*" {
        # ... to get it in a match group that can then be stored in a variable:
        set "subject" "${1}";
    }

    # We can't "replace" a header, but we can delete (all instances of) it and
    # re-add (a single instance of) it:
    deleteheader "Subject";
    # Append/prepend as you see fit
    addheader :last "Subject" "[Foo-List] ${subject}";
    # Note that the header is added ":last" (so it won't appear before possible
    # "Received" headers).
}

Source: https://superuser.com/a/1502589

And my actual use-case:

require ["body","fileinto", "regex", "variables","editheader"];

if header :contains "subject" ["(Issue #","(PR #"] {
  # Match the entire subject ...
  if header :matches "Subject" "*" {
    # ... to get it in a match group that can then be stored in a variable:
    set "subject" "${1}";
  }
  # We can't "replace" a header, but we can delete (all instances of) it and
  # re-add (a single instance of) it:
  # Append/prepend as you see fit
  # Note that the header is added ":last" (so it won't appear before possible
  # "Received" headers).

  # Closed #873.
  if body :raw :contains "Closed #" {
    deleteheader "Subject";
    addheader :last "Subject" "(Closed) ${subject}";
  }
  # Merged #310
  if body :raw :contains "Merged #" {
    deleteheader "Subject";
    addheader :last "Subject" "(Merged) ${subject}";
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.