summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsendmailadvanced.in86
1 files changed, 31 insertions, 55 deletions
diff --git a/sendmailadvanced.in b/sendmailadvanced.in
index c0092cc..5904f46 100755
--- a/sendmailadvanced.in
+++ b/sendmailadvanced.in
@@ -21,10 +21,8 @@ neueAdressaten() {
oldIFS="${IFS}"
IFS=','
- for adressat in ${adressatenString}
- do
- if [[ "${adressat}" == *"<"*">"* ]]
- then
+ for adressat in ${adressatenString}; do
+ if [[ "${adressat}" == *"<"*">"* ]]; then
adressat="${adressat#*<}"
adressat="${adressat%>*}"
fi
@@ -46,8 +44,7 @@ stempeln() {
}
gpgAdressaten() {
- for adressat in "${!adressaten[@]}"
- do
+ for adressat in "${!adressaten[@]}"; do
if \
(
gpg --with-colons --list-public-keys "${adressat}" 2> /dev/null | \
@@ -59,8 +56,7 @@ gpgAdressaten() {
) | \
sort | \
uniq -d | \
- grep -q '\S'
- then
+ grep -q '\S'; then
echo -n "-r ${adressat} "
else
printf -- '-r %s ' "${gpg_recipients[@]}"
@@ -90,12 +86,10 @@ dForced=false
eForced=false
sForced=false
-if [ -r #ETCDIR#/sendmailadvanced.conf ]
-then
- . #ETCDIR#/sendmailadvanced.conf
+if [ -r '#ETCDIR#/sendmailadvanced.conf' ]; then
+ . '#ETCDIR#/sendmailadvanced.conf'
else
- for konfig in $(readlink -f "$0").conf $(find . -name sendmailadvanced.conf 2> /dev/null)
- do
+ for konfig in $(readlink -f "$0").conf $(find . -name sendmailadvanced.conf 2> /dev/null); do
[ -r "${konfig}" ] || continue
. "${konfig}"
break
@@ -110,8 +104,7 @@ which hashcash &> /dev/null || stamp=false
eval set -- "$(getopt -o eh:i:st --long encrypt,no-encrypt,hook:,help,inline:,no-inline,stamp,no-stamp,version -n "$(basename "$0")" -- "$@" || echo verwendung)"
-while true
-do
+while true; do
case "$1" in
-h|--hook)
shift
@@ -171,23 +164,20 @@ done
[ $# -ne 0 ] && verwendung
MAILER="cantfind"
-for executable in sendmail msmtp
-do
- for prefix in #BINDIR# /usr/bin /usr/sbin /bin /sbin
- do
- [ "${MAILER}" == "cantfind" ] && [ -x ${prefix}/${executable} ] && MAILER="${prefix}/${executable}"
+for executable in sendmail msmtp; do
+ for prefix in '#BINDIR#' '/usr/bin' '/usr/sbin' '/bin' '/sbin'; do
+ [ "${MAILER}" == "cantfind" ] && [ -x "${prefix}/${executable}" ] && MAILER="${prefix}/${executable}"
done
done
-if [ -z "${datei}" ] && [ "${MAILER}" == "cantfind" ]
-then
+if [ -z "${datei}" ] && [ "${MAILER}" == "cantfind" ]; then
>&2 echo "ERROR: Can't find suitable mailer."
exit 1
fi
-(
+{
[ -z "${datei}" ] && cat || cat "${datei}"
-) | \
+} | \
(
IFS=''
adressatenString=""
@@ -196,35 +186,28 @@ fi
unset adressaten
declare -A adressaten
adressatenSammeln=false
- while read -r zeile
- do
+ while read -r zeile; do
echo "${zeile}" | grep -q "\S" || break
s="${zeile}"
- if [ "${s:0:3}" == "To:" ] || [ "${s:0:3}" == "Cc:" ]
- then
+ if [ "${s:0:3}" == "To:" ] || [ "${s:0:3}" == "Cc:" ]; then
adressatenSammeln=true
s=" ,${s:4}"
fi
- if [ ! "${s:0:1}" == " " ]
- then
+ if [ ! "${s:0:1}" == " " ]; then
${adressatenSammeln} && neueAdressaten
adressatenSammeln=false
fi
${adressatenSammeln} && adressatenString="${adressatenString}${s}"
- if ${encrypt}
- then
- if [ "${zeile:0:14}" == "Content-Type: " ]
- then
+ if ${encrypt}; then
+ if [ "${zeile:0:14}" == "Content-Type: " ]; then
contentType="${zeile}"
continue
fi
- if [ "${zeile:0:27}" == "Content-Transfer-Encoding: " ]
- then
+ if [ "${zeile:0:27}" == "Content-Transfer-Encoding: " ]; then
contentTE="${zeile}"
continue
fi
- if [ "${zeile:0:14}" == "MIME-Version: " ]
- then
+ if [ "${zeile:0:14}" == "MIME-Version: " ]; then
continue
fi
fi
@@ -233,20 +216,17 @@ fi
${stamp} && stempeln
- body="$(
+ body=$(
(
- for hookParam in "${hooks[@]}"
- do
+ for hookParam in "${hooks[@]}"; do
body_header_hook "${hookParam}"
done
cat
- for hookParam in "${hooks[@]}"
- do
+ for hookParam in "${hooks[@]}"; do
body_footer_hook "${hookParam}"
done
) | \
- if ${encrypt}
- then
+ if ${encrypt}; then
(
echo "${contentType}"
echo "${contentTE}"
@@ -254,19 +234,17 @@ fi
cat
echo ''
) | \
- eval "gpg -e --no-tty --batch -a -s $(gpgAdressaten | sed 's| $||')"
+ gpg -e --no-tty --batch -a -s $(gpgAdressaten | sed 's| $||')
else
cat
fi
- )"
+ )
- if ${encrypt}
- then
+ if ${encrypt}; then
boundary=""
while
echo "${body}" | \
- grep -q "${boundary}"
- do
+ grep -q "${boundary}"; do
boundary="$(gen_boundary)"
done
@@ -291,16 +269,14 @@ fi
echo "${zeile}"
echo "${body}"
- if ${encrypt}
- then
+ if ${encrypt}; then
echo ''
echo '--'"${boundary}"'--'
fi
) | \
(
- if [ -z "${datei}" ]
- then
+ if [ -z "${datei}" ]; then
${MAILER} -t
else
tmpFile="$(mktemp)"