#!/usr/bin/perl -w use strict; use warnings; use IO::Socket; use Sys::Hostname; my $EMAIL = 'root@localhost'; # change this my $SERVER = "127.0.0.1"; # change this, too my $CONFIG = "/usr/local/etc/syswatch.conf"; my $HOSTNAME = hostname; while (<>) { my $match; if (open(FH, $CONFIG)) { foreach my $pattern() { $pattern =~ s/\r|\n//g; if ($pattern !~ s/^!//) { last if $match; $match = /$pattern/; } elsif (/$pattern/) { $match = 0; last; } } close(FH); } next if !$match; my $s = new IO::Socket::INET(PeerAddr => $SERVER, PeerPort => 25, Proto => "tcp"); next if !$s; my $tmp = <$s>; print $s "HELO $HOSTNAME\n"; $tmp = <$s>; print $s "MAIL FROM:\<$EMAIL\>\n"; $tmp = <$s>; print $s "RCPT TO:\<$EMAIL\>\n"; $tmp = <$s>; print $s "DATA\n"; $tmp = <$s>; s/^\.$/../; print $s <