summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsendmailadvanced55
1 files changed, 33 insertions, 22 deletions
diff --git a/sendmailadvanced b/sendmailadvanced
index 3cd015d..12a327c 100755
--- a/sendmailadvanced
+++ b/sendmailadvanced
@@ -23,7 +23,7 @@ else
fi
-eval set -- "$(getopt -o eh:i:st --long encrypt,hook:,inline:,no-hooks,stamp -n "$(basename "$0")" -- "$@" || echo verwendung)"
+eval set -- "$(getopt -o eh:i:st --long encrypt,hook:,inline:,no-hooks,stamp -n "$(basename "$0")" -- "$@")"
while true
do
@@ -33,6 +33,7 @@ do
hooks[${#hooks[@]}]="$1"
;;
-i|--inline)
+ echo "inline erkannt"
shift
datei="$1"
;;
@@ -83,32 +84,42 @@ fi
) | \
(
IFS=''
- while read -r s
+ adressatenString=""
+ adressatenSammeln=false
+ while read -r zeile
do
- echo "${s}"
+ echo "${zeile}" | grep -q "\S" || break
+ s="${zeile}"
if [ "${s:0:3}" == "To:" ] || [ "${s:0:3}" == "Cc:" ]
then
- s="${s:4}"
- if [[ "${s}" == *"<"*">"* ]]
- then
- s="${s#*<}"
- s="${s%>*}"
- fi
- tos[${#tos[@]}]="${s}"
- elif [ "${s:0:8}" == "Subject:" ]
- then
- break
- fi
- done
- ${stamp} && hashcash -b ${hashcash_bits} -Xm "${tos[@]}"
- while read s
- do
- echo "${s}"
- if [ "${s}" == "" ]
- then
- break
+ adressatenSammeln=true
+ s=" ,${s:4}"
fi
+ [ "${s:0:1}" == " " ] || adressatenSammeln=false
+ ${adressatenSammeln} && adressatenString="${adressatenString}${s}"
+ echo "${zeile}"
done
+
+ if ${stamp}
+ then
+ IFS=','
+ for adressat in ${adressatenString}
+ do
+ if [[ "${adressat}" == *"<"*">"* ]]
+ then
+ adressat="${adressat#*<}"
+ adressat="${adressat%>*}"
+ fi
+ adressat="$(
+ echo "${adressat}" | \
+ tr -d "[:space:]"
+ )"
+ echo "${adressat}" | grep -q "\S" || continue
+ hashcash -b ${hashcash_bits} -Xm "${adressat}"
+ done
+ fi
+ echo "${zeile}"
+
(
${applyHooks} && body_header_hook "${hooks[@]}"
cat