summaryrefslogtreecommitdiffstats
path: root/examplescripts/Example7
blob: 7766b4b70e7c3afbdc695c687f9c6218be2a500f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /bin/sh
#
# This is a script from the smartmontools examplescripts/ directory.
# It can be used as an argument to the -M exec Directive in
# /etc/smartd.conf, in a line like
# ... -m root@localhost -M exec /path/to/this/file
#
# See also: smartd.conf(5), smartd(8).
#
# $Id: Example7 5442 2023-01-26 18:15:26Z chrfranke $

if [ $# -lt 3 ] || [ "$1" != "-s" ]; then
  echo "Usage: $0 -s SUBJECT ADDRESS... < MESSAGE"
  exit 1
fi

SUBJECT=$2
shift; shift
ADDRESS=$*

exec /usr/sbin/sendmail $ADDRESS <<EOF
Subject: $SUBJECT
To: $(echo $ADDRESS | sed 's/ /, /g')

$(cat -)
EOF