I have a dev box using xubuntu 16.04. I have setup ssmtp to handle mail and can send email. I tested it with
mail myemail@mydomain.com < .~/.bashrc'
And it worked fine. I have a cron job running every minute which creates output that should get sent by my cron. 'grep CRON /var/log/syslog' gives me
Sep 27 15:22:01 epdev CRON[19569]: (eventpuddle) CMD (cd /home/eventpuddle/eventpuddle/batch; ./scrape_check_todays_logs.bash )
Sep 27 15:22:01 epdev sSMTP[19571]: Creating SSL connection to host
Sep 27 15:22:01 epdev sSMTP[19571]: SSL connection using RSA_AES_128_CBC_SHA1
Sep 27 15:22:03 epdev sSMTP[19571]: Sent mail for root@sun.prsc (221 2.0.0 Bye) uid=1000 username=eventpuddle outbytes=816
If i 'sudo -i' and type mail I am told there is no mail. /etc/ssmtp/ssmtp.conf is:
root=myemail@mydomain.com
mailhub=mail.myhoestingpeople.com:2525
hostname=sun.prsc
UseSTARTTLS=YES
AuthUser=user
AuthPass=password
FromLineOverride=YES
UseTLS=YES
cront entery is
* * * * * ( cd /home/eventpuddle/eventpuddle/batch; ./scrape_check_todays_logs.bash )
./scrape_check_todays_logs.bash is
#!/bin/bash
# scrape_check_todays_logs.bash (c) 2017 Ben Edwards (http://funkytwig.com/it)
# Check logfiles for today and email them if there are any errors.
. ~/.bashrc
[ -z "$HOME" ] && { echo '$HOME not set'; exit 1; }
[ -z "$ADMIN_EMAIL" ] && { echo '$ADMIN_EMAIL not set'; exit 1; }
t=/tmp/`basename $0 .bash`.$$.tmp
d=$HOME
grep -l "$d" log/*`date +%A`* > $t
cat $t | while read line
do
echo "mail $line"
mail -s "eventpuddle batch failuure $line" $ADMIN_EMAIL < $line
done
grep EXCLUD log/*`date +%A`* > $t
mail -s 'eventpuddle exclusions' $ADMIN_EMAIL < $t
Not sure what other info to give but will if asked.