The following will work in both FreeNAS 0.7 and FreeNAS 8.0.1:
Code:
#!/bin/bash
FROM=me@mydomain.com
TO=me@mydomain.com
SUBJECT="`hostname`: Test Email"
BODY=""
PRINTF=/usr/bin/printf
MSMTP=/usr/local/bin/msmtp
MSMTPCONF=/var/etc/msmtp.conf
#...
BODY="Something"
#...
# Send email in FreeNAS 0.7.x
[ -f $MSMTP ] && $PRINTF "From:$FROM\nTo:$TO\nSubject:$SUBJECT\n\n$BODY" | $MSMTP --file=$MSMTPCONF -t
# Send email in FreeNAS 8.0.1+
[ ! -f $MSMTP ] && $PRINTF "$BODY" | mail -s "$SUBJECT" $TO