Monday, February 7, 2011

Email Available Updates for Debian

Before you proceed below please check:
  • Simple apt daily update script, see here.
  • Configure exim4 to send messages by smarthost, no local mail, see here.
We are going enhance daily update script by ability to send a list of new updates to mail.


# Download only; package files are only retrieved, not 
# unpacked or installed.
apt-get -dqq update
apt-get -dyqq upgrade

has_upgrades=$(apt-get -s upgrade | grep ^Inst)
if [ "$has_upgrades" ] ; then
    echo "$has_upgrades" | mail -s \
    "Updates for $(hostname) on $(date +%Y-%m-%d)" \
Alternatively consider using apticron, read more here.

Configure exim4 to send messages by smarthost, no local mail

This option of exim4 configuration is suitable for a client system which is not responsible for a local e-mail domain. All locally generated e-mail is sent to the smarthost.
  • Smarthost FQDN:
  • Client:
Here are few simple steps to configure:
  1. The easiest way is to reconfigure exim4-config package:
    dpkg-reconfigure exim4-config
  2. General type of mail configuration:
       mail sent by smarthost; no local mail
    System mail name:
    IP-addresses to listen on for incoming SMTP connections:
    Other destinations for which mail is accepted:
    Visible domain name for local users:
    IP address or host name of the outgoing smarthost:
    Keep number of DNS-queries minimal (Dial-on-Demand)?
    Split configuration into small files?
Let verify it is working:
echo "test message" | mail -s "test" user1@dev.local
... exim4 log (file /var/log/exim4/mainlog):
1PmoNq-0001or-55 <= (localhost) [192.168.XX.XXX] P=esmtps X=TLS1.0:RSA_AES_256_CBC_SHA1:32 S=715 id=E1PmoNq-0001f6-08@localhost
1PmoNq-0001or-55 => user1  R=local_user T=maildir_home
1PmoNq-0001or-55 Completed
At this point user1 should be able to receive your test message.