User Tools

Site Tools


howtos:send_mails_with_curl

Differences

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

Link to this comparison view

howtos:send_mails_with_curl [d/m/Y H:i] (current)
domingo created
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: d/m/Y H:i by domingo