in reply to Check for MTA or DNS troubles

You might want to stick a die and a message on

my $log = `tail -$lines /var/log/syslog|egrep -i '$day'|egrep -i 'defe +rred'`;
such as
my $log = `tail -$lines /var/log/syslog|egrep -i '$day'|egrep -i 'defe +rred'` or die ("No Deferred messages\n");
or place a check for nothing found. There is a chance no deferred mail gets logged and with the current code you get these messages when the job runs.
Use of uninitialized value in pattern match (m//) at dm line 45. Use of uninitialized value in pattern match (m//) at dm line 51. Use of uninitialized value in subtraction (-) at dm line 58. Use of uninitialized value in subtraction (-) at dm line 58. deferred messages ocurred withing 1 minute of each other