{"id":89,"date":"2010-09-23T10:24:16","date_gmt":"2010-09-23T08:24:16","guid":{"rendered":"https:\/\/thebc.ch\/blog\/?p=89"},"modified":"2013-02-01T13:18:27","modified_gmt":"2013-02-01T12:18:27","slug":"email-notification-with-cron-apt-via-mailx","status":"publish","type":"post","link":"https:\/\/thebc.ch\/blog\/?p=89","title":{"rendered":"Email notification with cron-apt via mailx"},"content":{"rendered":"<p>1. Install and configure <strong>cron-apt<\/strong><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\"># apt-get install cron-apt bsd-mailx ssmtp &nbsp; &nbsp;# Or msmtp<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>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<em>:<\/em><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/><\/div><\/td><td><div class=\"text codecolorer\">MAILTO=&quot;user@example.com&quot;<br \/>\nMAILON=&quot;upgrade&quot;\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 #to only be notified if updates are avaiable<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<\/p>\n<p>2. Be notified<\/p>\n<p>To be notified via mailx, you have to copy the 9-notify from examples to actions.d and edit them.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\"># cp \/usr\/share\/doc\/cron-apt\/examples\/9-notify \/etc\/cron-apt\/action.d\/<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/><\/div><\/td><td><div class=\"text codecolorer\"># vi \/etc\/cron-apt\/action.d\/9-notify<br \/>\n-q -q --no-act upgrade MAILON=user@example.com<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<\/p>\n<p>3. Configure ssmtp<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;height:300px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/><\/div><\/td><td><div class=\"text codecolorer\">#<br \/>\n# Config file for sSMTP sendmail<br \/>\n#<br \/>\n# The person who gets all mail for userids &amp;lt; 1000<br \/>\n# Make this empty to disable rewriting.<br \/>\nroot=someuser@thebc.ch<br \/>\n<br \/>\n# The place where the mail goes. The actual machine name is required no<br \/>\n# MX records are consulted. Commonly mailhosts are named mail.domain.com<br \/>\nmailhub=mailbox.thebc.ch\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 # Or the IP-address<br \/>\n<br \/>\n# Where will the mail seem to come from?<br \/>\n#rewriteDomain=<br \/>\n<br \/>\n# The full hostname<br \/>\nhostname=thisserver.thebc.ch<br \/>\n<br \/>\n# Are users allowed to set their own From: address?<br \/>\n# YES - Allow the user to specify their own From: address<br \/>\n# NO - Use the system generated From: address<br \/>\nFromLineOverride=YES<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<br \/>\n4. Check your installation<\/p>\n<p>To check if all is working as you expect run:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\"># cron-apt -s<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Install and configure cron-apt 1# apt-get install cron-apt bsd-mailx ssmtp &nbsp; &nbsp;# 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 &hellip; <a href=\"https:\/\/thebc.ch\/blog\/?p=89\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,5,16],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-debian","category-linux","category-software"],"_links":{"self":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":24,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":2746,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions\/2746"}],"wp:attachment":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}