#! /usr/bin/perl -w
# Author: Adrian Puente Z. (apuente _at_ hackarandas _dot_ com)
# It checks for open relay SMTP servers sending an email to a configured email.
# Made in perl and requires the MIME::Lite and Net::SMTP libraries.
# 
# perl -MCPAN -e 'install MIME::Lite'
# perl -MCPAN -e 'install Net::SMTP'


use MIME::Lite;
use Net::SMTP;
use strict;

if ( $#ARGV == -1 )
{
	print "Sintaxis: enviamail.pl [IP Servidor]\n";
	exit;
}

my $server = $ARGV[0];

				#You can leave this like this.
my $msg = MIME::Lite->new(From    => 'bogus@mail.com',  
				# Your email so you can check that it worked.
                       To      => 'destination@mail.com',
                       Subject => 'Open relay server found! '.$server,
                       Type    => 'multipart/mixed');

$msg->attach(Type        => 'text/html',
             Data        => 'Server '.$server.' with open relay');

print "Testing ".$server."\n";
MIME::Lite->send('smtp', $server , Timeout=>10);
$msg->send;
print "Done: ".$server."\n";
