use Net::SMTP; my $lengthfile="\var\logs\www\myapp.log.length"; my $logfile="\var\logs\www\myapp.log"; my $applicationname="myapplication"; my $smtpserver="mysmtp"; my $from=q{serveradmin@blah.net}; my $to=q{serveradmin@blah.net}; open FILE, $lengthfile || die "Couldn't open lengthfile"; my $length=; close FILE; my $size= -s $logfile; if($size>$length){ open LOG, $logfile || die "Couldn't open logfile"; seek (LOG, $length+1,0); my $smtp=Net::SMTP->new($smtpserver,Timeout=>30); $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: $applicationname Error\n"); $smtp->datasend("\n"); while(){ $smtp->datasend($_); } $smtp->dataend(); $smtp->quit(); open FILE, ">$lengthfile" || die "Couldn't open lengthfile for writing"; print FILE $size; close FILE; }