summaryrefslogtreecommitdiff
path: root/sendmailadvanced/sendmailadvanced
diff options
context:
space:
mode:
Diffstat (limited to 'sendmailadvanced/sendmailadvanced')
-rw-r--r--sendmailadvanced/sendmailadvanced49
1 files changed, 49 insertions, 0 deletions
diff --git a/sendmailadvanced/sendmailadvanced b/sendmailadvanced/sendmailadvanced
new file mode 100644
index 00000000..7b5e7fe5
--- /dev/null
+++ b/sendmailadvanced/sendmailadvanced
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+MAILER="cantfind"
+
+for executable in sendmail msmtp
+do
+ for prefix in /usr/bin /usr/sbin /bin /sbin
+ do
+ [ "${MAILER}" == "cantfind" ] && [ -x ${prefix}/${executable} ] && MAILER="${prefix}/${executable}"
+ done
+done
+
+if [ "${MAILER}" == "cantfind" ]
+then
+ >&2 echo "ERROR: Can't find suitable mailer."
+ exit 1
+fi
+
+(
+ . /etc/sendmailadvanced.conf
+
+ tos=""
+ while read s
+ do
+ echo "${s}"
+ if [ "${s:0:3}" == "To:" ] || [ "${s:0:3}" == "Cc:" ]
+ then
+ tos="${tos} ${s:4}"
+ fi
+ if [ "${s:0:8}" == "Subject:" ]
+ then
+ break
+ fi
+ done
+ hashcash -b ${hashcash_bits} -Xm ${tos}
+ while read s
+ do
+ echo "${s}"
+ if [ "${s}" == "" ]
+ then
+ break
+ fi
+ done
+ (
+ body_header_hook $@
+ cat
+ body_footer_hook $@
+ ) | gpg -e -a -s -r ${gpg_recipient}
+) | ${MAILER} -t