1. Install and configure cron-apt
# apt-get install cron-apt bsd-mailx ssmtp # Or msmtp
We want only be notified of new updates. We want not to install them automatically. All settings are optimal for this action by default. And the cronjob will also run every day 4am by default. All you have to change in /etc/cron-apt/config is the following:
MAILON="upgrade" #to only be notified if updates are avaiable
2. Be notified
To be notified via mailx, you have to copy the 9-notify from examples to actions.d and edit them.
# cp /usr/share/doc/cron-apt/examples/9-notify /etc/cron-apt/action.d/
# vi /etc/cron-apt/action.d/9-notify
-q -q --no-act upgrade MAILONemail@example.com
3. Configure ssmtp
# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=mailbox.thebc.ch # Or the IP-address
# Where will the mail seem to come from?
# The full hostname
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
4. Check your installation
To check if all is working as you expect run:
# cron-apt -s