User Tools

Site Tools


howtos:send_mails_with_curl
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


howtos:send_mails_with_curl [30/05/2020 19:51] (current) – created domingo
Line 1: Line 1:
 +====== 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:
 +
 +<code>
 +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
 +</code>
 +
 +Don't underestimate the power of Curl :-)
howtos/send_mails_with_curl.txt · Last modified: 30/05/2020 19:51 by domingo