summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsendmailadvanced.in38
1 files changed, 34 insertions, 4 deletions
diff --git a/sendmailadvanced.in b/sendmailadvanced.in
index c1aef2e..547d9a0 100755
--- a/sendmailadvanced.in
+++ b/sendmailadvanced.in
@@ -17,7 +17,7 @@ verwendung() {
exit 1
}
-stempeln() {
+neueAdressaten() {
oldIFS="${IFS}"
IFS=','
@@ -33,7 +33,7 @@ stempeln() {
tr -d "[:space:]"
)"
echo "${adressat}" | grep -q "\S" || continue
- hashcash -b ${hashcash_bits} -Xm "${adressat}"
+ adressaten["${adressat}"]=1
done
adressatenString=""
@@ -41,6 +41,34 @@ stempeln() {
IFS="${oldIFS}"
}
+stempeln() {
+ hashcash -b ${hashcash_bits} -Xm "${!adressaten[@]}"
+}
+
+gpgAdressaten() {
+ local kenneAlle
+ for adressat in "${!adressaten[@]}"
+ do
+ if \
+ (
+ gpg --with-colons --list-public-keys "${adressat}" | \
+ grep '^uid:[mfuw]:' | \
+ cut -d: -f10 | \
+ tr '<>' '\n' | \
+ sort -u
+ echo "${adressat}"
+ ) | \
+ sort | \
+ uniq -d | \
+ grep -q '\S'
+ then
+ echo -n "-r ${adressat} "
+ else
+ echo -n "-r ${gpg_recipient} "
+ fi
+ done
+}
+
datei=""
encrypt=true
stamp=true
@@ -147,6 +175,8 @@ fi
(
IFS=''
adressatenString=""
+ unset adressaten
+ declare -A adressaten
adressatenSammeln=false
while read -r zeile
do
@@ -159,7 +189,7 @@ fi
fi
if [ ! "${s:0:1}" == " " ]
then
- ${adressatenSammeln} && ${stamp} && stempeln
+ ${adressatenSammeln} && neueAdressaten
adressatenSammeln=false
fi
${adressatenSammeln} && adressatenString="${adressatenString}${s}"
@@ -181,7 +211,7 @@ fi
done
) | \
(
- ${encrypt} && gpg -e -a -s -r ${gpg_recipient} || cat
+ ${encrypt} && gpg -e -a -s -r $(gpgAdressaten) || cat
)
) | \
(