summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsendmailadvanced18
1 files changed, 17 insertions, 1 deletions
diff --git a/sendmailadvanced b/sendmailadvanced
index 64a0152..37b73e8 100755
--- a/sendmailadvanced
+++ b/sendmailadvanced
@@ -1,5 +1,21 @@
#!/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
@@ -30,4 +46,4 @@
cat
body_footer_hook $@
) | gpg -e -a -s -r ${gpg_recipient}
-) | /usr/sbin/sendmail -t
+) | ${MAILER} -t