require "vnd.stalwart.testsuite"; require "relational"; test "RFC Example 1" { require ["enotify", "fileinto", "variables"]; if header :contains "from" "boss@example.org" { notify :importance "1" :message "This is probably very important" "mailto:alm@example.com"; # Don't send any further notifications stop; } if header :contains "to" "sievemailinglist@example.org" { # :matches is used to get the value of the Subject header if header :matches "Subject" "*" { set "subject" "${1}"; } # :matches is used to get the value of the From header if header :matches "From" "*" { set "from" "${1}"; } notify :importance "3" :message "[SIEVE] ${from}: ${subject}" "mailto:alm@example.com"; fileinto "INBOX.sieve"; } } test "RFC Example 2" { require ["enotify", "fileinto", "variables", "envelope"]; if header :matches "from" "*@*.example.org" { # :matches is used to get the MAIL FROM address if envelope :all :matches "from" "*" { set "env_from" " [really: ${1}]"; } # :matches is used to get the value of the Subject header if header :matches "Subject" "*" { set "subject" "${1}"; } # :matches is used to get the address from the From header if address :matches :all "from" "*" { set "from_addr" "${1}"; } notify :message "${from_addr}${env_from}: ${subject}" "mailto:alm@example.com"; } } test "RFC Example 3" { require ["enotify", "variables"]; set "notif_method" "xmpp:tim@example.com?message;subject=SIEVE;body=You%20got%20mail"; if header :contains "subject" "Your dog" { set "notif_method" "tel:+14085551212"; } if header :contains "to" "sievemailinglist@example.org" { set "notif_method" ""; } if not string :is "${notif_method}" "" { notify "${notif_method}"; } if header :contains "from" "boss@example.org" { # :matches is used to get the value of the Subject header if header :matches "Subject" "*" { set "subject" "${1}"; } # don't need high importance notification for # a 'for your information' if not header :contains "subject" "FYI:" { notify :importance "1" :message "BOSS: ${subject}" "tel:+14085551212"; } } } test "RFC Example 5" { require ["enotify"]; if notify_method_capability "xmpp:tim@example.com?message;subject=SIEVE" "Online" "yes" { notify :importance "1" :message "You got mail" "xmpp:tim@example.com?message;subject=SIEVE"; } else { notify :message "You got mail" "tel:+14085551212"; } } test "RFC Example 6" { require ["enotify", "variables"]; set :encodeurl "body_param" "Safe body&evil=evilbody"; notify "mailto:tim@example.com?body=${body_param}"; } test "Duplicate recipients" { require "enotify"; notify :message "Incoming stupidity." "mailto:stephan@example.org%2cstephan@friep.example.com%2cidiot@example.org"; notify :message "There it is." "mailto:tss@example.net%2cstephan@example.org%2cidiot@example.org%2cnico@frop.example.org%2cstephan@friep.example.com"; }