#!/usr/bin/perl -w

	$| = 1;

	my $smtp = 'smtp.gmail.com';

	print "Content-type: text/plain; charset=windows-1251\n\n" if $ENV{HTTP_USER_AGENT};

	unless (eval ("use strict; return 1;")) { print "Error"; } else { print "Ok"; }
		unless (eval ("use Sys::Hostname; return 1;")) { print "Error"; } else { print "Ok"; }
		unless (eval ("use POSIX qw(setsid); return 1;")) { print "Error"; } else { print "Ok"; }
		unless (eval ("use Errno qw(EINPROGRESS); return 1;")) { print "Error"; } else { print "Ok"; }
		unless (eval ("use IO::Socket qw(:DEFAULT :crlf); return 1;")) { print "Error"; } else { use IO::Socket qw(:DEFAULT :crlf); print "Ok"; }
		unless (eval ("use IO::Select; return 1;")) { print "Error"; } else { print "Ok"; }
	
		my $s = IO::Socket::INET->new(Proto => "tcp", LocalPort => 36000, Listen => SOMAXCONN, Reuse => 1);
	unless ($s) { print "Error"; } else { close $s; print "Ok"; }
	
		
	$r = (gethostbyname $smtp)[4];
	unless ($r) { print "Error > Can't resolve SMTP hostname"; exit; }
	$s = IO::Socket::INET->new(Proto => "tcp", Type => SOCK_STREAM);
	unless ($s) { print "Error > Can't create socket > $!"; exit; }
	unless ($s->connect(pack ("Sna4x8", 2, 25, $r))) { close $s; print "Error > Can't connect > $!"; exit; }
	$r = <$s>; close $s;
	if (length $r) { print "Ok\n$r"; } else { print "Error > Can't read response"; }
