From 18834de56e2bb62e97150ca9ee8b117d24937609 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Thu, 2 Feb 2017 21:36:50 +0100 Subject: [PATCH] Handle forwards as aliases with local copy --- dovecot/conf/pigeonhole-sieve.dict | 14 -------------- dovecot/sieve/before.sieve | 5 ----- dovecot/sieve/bin/forward | 13 ------------- postfix/conf/sqlite-virtual_alias_maps.cf | 2 +- 4 files changed, 1 insertion(+), 33 deletions(-) delete mode 100755 dovecot/sieve/bin/forward diff --git a/dovecot/conf/pigeonhole-sieve.dict b/dovecot/conf/pigeonhole-sieve.dict index 2765edd1..ad99e3e1 100644 --- a/dovecot/conf/pigeonhole-sieve.dict +++ b/dovecot/conf/pigeonhole-sieve.dict @@ -34,17 +34,3 @@ map { username_field = email value_field = reply_body } - -map { - pattern = priv/forward_enabled - table = user - username_field = email - value_field = forward_enabled -} - -map { - pattern = priv/forward_destination - table = user - username_field = email - value_field = forward_destination -} diff --git a/dovecot/sieve/before.sieve b/dovecot/sieve/before.sieve index 8592a158..41774d90 100644 --- a/dovecot/sieve/before.sieve +++ b/dovecot/sieve/before.sieve @@ -22,8 +22,3 @@ if allof (string :is "${extdata.spam_enabled}" "1", if string :is "${extdata.reply_enabled}" "1" { vacation :days 1 :subject "${extdata.reply_subject}" "${extdata.reply_body}"; } - -if string :is "${extdata.forward_enabled}" "1" { - execute :pipe "forward" "${extdata.forward_destination}"; - keep; -} diff --git a/dovecot/sieve/bin/forward b/dovecot/sieve/bin/forward deleted file mode 100755 index 8bc03a0e..00000000 --- a/dovecot/sieve/bin/forward +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Get the mail content -FILENAME=/tmp/forward-$$ -cat > $FILENAME <&0 - -# Actually send the emails -IFS=',' read -ra RECIPIENTS <<< "$1" -for RECIPIENT in "${RECIPIENTS[@]}"; do - sendmail -S smtp $RECIPIENT < $FILENAME -done - -rm $FILENAME diff --git a/postfix/conf/sqlite-virtual_alias_maps.cf b/postfix/conf/sqlite-virtual_alias_maps.cf index 25fd24f5..0a4896b1 100644 --- a/postfix/conf/sqlite-virtual_alias_maps.cf +++ b/postfix/conf/sqlite-virtual_alias_maps.cf @@ -4,7 +4,7 @@ query = FROM (SELECT destination, email, wildcard, localpart FROM alias UNION - SELECT email AS destination, email, 0 as wildcard, localpart FROM user) + SELECT email||(CASE WHEN forward_enabled=1 THEN ','||forward_destination ELSE '' END) AS destination, email, 0 as wildcard, localpart FROM user) WHERE ( wildcard = 0