sub smtp_relay { my $ip = $q->param('ip') || 'localhost'; my $port = $q->param('port') || 25; my $timeout = $q->param('timeout') || 30; my $domain = $q->param('domain') ||'localhost'; my $to = $q->param('to') ||'you@yourdomain.com'; my $from = $q->param('from') ||'nobody@nowhere.com'; my $server = get_host_by_addr($ip); $ip = get_host_by_name($ip); my $message= "Test relay message for $server [$ip]. You will get this message only if $server is an OPEN RELAY \015\012.\015\012 "; print "Attempting to connect to SMTP $server [$ip] on port $port\n"; my $sock = IO::Socket::INET->new( PeerAddr => $ip, PeerPort => $port, Proto => 'tcp', Timeout => $timeout ); do{ print $CONN_FAILURE; return} unless $sock; $sock->autoflush(1); my $data = getline($sock); sendline( $sock, "HELO $domain" ); $data = getline($sock); sendline( $sock,"MAIL from: <$from>" ); $data = getline($sock); sendline( $sock, "RCPT to: <$to>" ); $data = getline($sock); if ($data =~ m/^550/ ) { sendline( $sock, 'QUIT' ); print "