Вот код небольшой.
Правда только для unix mail сервера подходит.
#!/usr/bin/perl
$mailserver=\'mail.server.com\'; # здесь свой нужно подставить
$From=\'Me\';
$To=\'to_adress@mail.com\';
$Subject=\'Test Message\';
$Message="Test ok!\\nTest ok!\\nTest ok!";
$error=sendEmail($From,$To,$Subject,$Message);
if ($error)
{ print "\\nError: $error\\n";
}
sub sendEmail
{ local ($From,$To,$Subject,$Message)=@_;
local ($remotehost,$port)=($mailserver,25);
local ($AF_INET,$SOCK_STREAM,$sockaddr)=(2,1,\'S n a4 x8\');
local ($thisaddr,$thataddr);
$thisaddr=gethostbyname("");
$thataddr=gethostbyname($remotehost);
unless(socket(S, $AF_INET, $SOCK_STREAM, getprotobyname(\'tcp\')))
{ return 41;
}
unless(bind(S,pack($sockaddr, $AF_INET, 0, $thisaddr)))
{ return 42;
}
unless(connect(S,pack($sockaddr, $AF_INET, $port, $thataddr)))
{ return 43;
}
select(S); $|=1; select(STDOUT);
print S "helo uicserver\\n";
print $l=;
print S "mail from: <>\\n";
print $l=;
print S "rcpt to: $To\\n";
print $l=;
print S "data\\n";
print $l=;
print S "Subject: $Subject\\n";
print S "From: $From\\n";
print S "To: $To\\n";
print S "Content-Type: text\\/plain\\n\\n";
print S "$Message\\n";
print S "\\n.\\n";
print $l=;
print S "quit\\n";
print $l=;
close(S);
return 0;
}