User Tools

Site Tools


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://$(hostname -f) --mail-from root@$(hostname -f) --mail-rcpt --silent -T - <<< $(echo -e "From: Root <root@$(hostname -f)>\nTo: John <>\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: 30/05/2020 17:51 by domingo