#!/bin/bash
#
# $1 Empfänger
# $2 subject 
# $3 content
#

if [ -z "$1" ]; then
   return 255
fi

if [ -z "$2" ]; then
   return 255
fi

if [ -z "$3" ]; then
   /usr/bin/systemctl status --full "$2" | /usr/bin/mail -Ssendwait -s "systemd: $2" "$1"
else
   recipient="$1"
   shift
   subject="$1"
   shift
   /usr/bin/echo "$@" | /usr/bin/mail -Ssendwait -s "$subject" "$recipient"
fi

exit 0
