diff --git a/metche b/metche index 1bfccde..7ca590b 100755 --- a/metche +++ b/metche @@ -71,15 +71,34 @@ fi } +add_header() { + local subject="$1"; + echo "Subject: $subject"; + echo "To: $EMAIL_ADDRESS"; + echo + cat; +} + +_mail() { + local subject="$1"; + if which mail > /dev/null ; then + LC_ALL="$LOCALE" mail -s "$subject" "$EMAIL_ADDRESS" + elif [ -x /usr/sbin/sendmail ]; then + LC_ALL="$LOCALE" add_header "$subject"|/usr/sbin/sendmail "$EMAIL_ADDRESS" + elif which mutt > /dev/null ; then + LC_ALL="$LOCALE" mutt -s "$subject" "$EMAIL_ADDRESS" + fi +} + email() { debug "* email $@ to $EMAIL_ADDRESS" local subject="`current_system` - $_MAIL_SUBJECT : $1" if [ $ENCRYPT_EMAIL = "yes" ]; then LC_ALL="$LOCALE" gpg --batch --armor --encrypt \ --recipient "$EMAIL_ADDRESS" | - LC_ALL="$LOCALE" mutt -s "$subject" "$EMAIL_ADDRESS" + LC_ALL="$LOCALE" _mail "$subject" else - LC_ALL="$LOCALE" mutt -s "$subject" "$EMAIL_ADDRESS" + LC_ALL="$LOCALE" _mail "$subject" fi }