howtos:send_mails_with_curl
Send mail with curl
I needed a way to know if a Docker container had updates to its software packages without installing them.
This way I would know that I needed to rebuild or update the base image behind the container.
This one-liner can be either merged into the base image or easily appended to a container crontab:
apt update;upgradable=$(apt list --upgradable);count=$(apt list --upgradable|wc -l);if [ $count -gt 1 ]; then curl --ssl-reqd smtp://mail.example.com/$(hostname -f) --mail-from root@$(hostname -f) --mail-rcpt info@example.com --silent -T - <<< $(echo -e "From: Root <root@$(hostname -f)>\nTo: John <john@example.com>\nSubject: Container $(hostname) has updates\n\n$(echo "$upgradable")"); fi
Don't underestimate the power of Curl
howtos/send_mails_with_curl.txt · Last modified: d/m/Y H:i by domingo