diff options
-rwxr-xr-x | sendmailadvanced.in | 76 |
1 files changed, 63 insertions, 13 deletions
diff --git a/sendmailadvanced.in b/sendmailadvanced.in index 218e4a1..2bcc3ba 100755 --- a/sendmailadvanced.in +++ b/sendmailadvanced.in @@ -192,29 +192,79 @@ fi adressatenSammeln=false fi ${adressatenSammeln} && adressatenString="${adressatenString}${s}" + if ${encrypt} + then + if [ "${zeile:0:14}" == "Content-Type: " ] || [ "${zeile:0:14}" == "MIME-Version: " ] + then + continue + fi + fi echo "${zeile}" done ${stamp} && stempeln - echo "${zeile}" - ( - for hookParam in "${hooks[@]}" - do - body_header_hook "${hookParam}" - done - cat - for hookParam in "${hooks[@]}" + body="$( + ( + for hookParam in "${hooks[@]}" + do + body_header_hook "${hookParam}" + done + cat + for hookParam in "${hooks[@]}" + do + body_footer_hook "${hookParam}" + done + ) | \ + if ${encrypt} + then + gpg -e -a -s $(gpgAdressaten | sed 's| $||') + else + cat + fi + )" + + if ${encrypt} + then + boundary="" + while + echo "${body}" | \ + grep -q "${boundary}" do - body_footer_hook "${hookParam}" + boundary="$( + base64 -w0 < /dev/urandom | \ + tr -d [/+] | \ + head -c 33 + )" done - ) | \ + + echo 'MIME-Version: 1.0' + echo 'Content-Type: multipart/encrypted;' + echo ' protocol="application/pgp-encrypted";' + echo ' boundary="'"${boundary}"'"' + echo '' + echo 'This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)' + echo '--'"${boundary}" + echo 'Content-Type: application/pgp-encrypted' + echo 'Content-Description: PGP/MIME version identification' + echo '' + echo 'Version: 1' + echo '' + echo '--'"${boundary}" + echo 'Content-Type: application/octet-stream; name="encrypted.asc"' + echo 'Content-Description: OpenPGP encrypted message' + echo 'Content-Disposition: inline; filename="encrypted.asc"' + fi + + echo "${zeile}" + echo "${body}" + if ${encrypt} then - gpg -e -a -s -r $(gpgAdressaten) - else - cat + echo '' + echo '--'"${boundary}"'--' fi + ) | \ ( if [ -z "${datei}" ] |