Emailing yourself your nightly maintenance logs

locked-computer-cartoonI run a nightly maintenance job on the computers in my lab to virus scan their Microsoft partitions and be sure their Linux partition is updated. The output goes into log files, which I want emailed to myself for review the next day so that I can fix any problems quickly.

One of the fundamental security rules that I follow is to remove all unnecessary software from my computers: there are lots of spammers abusing email and having a lab full of email servers sitting there just waiting for a spammer to break in and abuse them all night just does not leave me comfortable. The setup process for sendmail and postfix both seemed very non-intuitive to me: “/etc/hostname contains only the short computer’s name, while /etc/hosts contains the computer’s fully qualified domain name”, set up MX records for each and every computer so outside servers know they are legitimate.

ARGHHH! Too much. I just want to email myself the log files! Here is how to do it: five minutes or less.

I found a simple command line program that is in the Ubuntu / MINT repository and solves all this without need for any configuring. You need perl. It runs in Linux or Microsoft. Simply install it with

apt-get install sendemail

notice that says “sendemail” not “sendmail”. There is an “e” in the middle. Different program.

Then call it with something like this using the same smtp email server and email login information you would place into your desktop email client

sendemail -f -t -u “Test using sendEmail” -s -xu “email login” -xp “email password” -m “This is a test message”

Works first time. No configuring. Five minutes work, tops. Tells you if the mail was sent successfully or not.  I like that.

To send a file instead of typing the text into the command line use “-o message-file=logfilename” instead of the -m “This is a test message”.

Link to the project web site is

and the lead that tipped me off on this elegant solution is

Massive number of command line examples on that site.

Comments are closed