greetings all
i am looking for SMTP Server simulation in Perl, currently I am using Net::Server::Mail::SMTP package from cpan.org and i have configured an smtp server code all in perl. now what it does is that it connects to smtp from every system (windows and localhost) but carries on with smtp response and functionality only on localhost not through client. it displays an error when it connects through any client "500:Syntax error unrecognized command", i dont know where is the problem, my smtp and telnet ports on localhost are open , i dont know why it doesnt connect from client but only from localhost, besides it doesnot send an email even when i connect through localhost. please help. if anybody can send me the perl based smtp server code, that will be good, any suggestions im really worried , i've been working on this code from past 2 weeks but cannot solve the problem thx alot.

regards
fahad


PS. my smtp server code is


#!/usr/bin/perl
use Net::Server::Mail::SMTP;
use Net::Server::Mail;
use IO::Socket::INET;
use Net::Server::Mail;
use IO::Socket;
use Net::Server;

my @local_domains = qw(niit.edu.pk yahoo.com hotmail.com);
my $sock = IO::Socket::INET -> new (Listen => 5,
LocalAddr => '10.0.0.226',
Proto => 'tcp',
LocalPort => 25);
while ($conn = $sock->accept)
{
my $smtp = new Net::Server::Mail::SMTP socket => $conn;
$smtp->set_callback(HELO => \&helo_handle);
$smtp->set_callback(RCPT => \&validate_recipient);
$smtp->set_callback(DATA => \&queue_message);
$smtp->process();
$conn->close();
print "--------------------------- SMTP Packet Capture --------------------------------","\n";
print "-------------------------------------------------------------------------------","\n";
print "-------------------------------------------------------------------------------","\n";
}
sub helo_handle
{
my($session, $hostname) = @_;

if($hostname eq 'localhost')
{
return(0, 553, q(ZzzzzzzzzzzzzZzzzzzzzzzzzzz:P:P));
}

# don't forgot to return a success reply if you are happy with
# command's value
return 1;
}

sub validate_recipient
{
my($session, $recipient) = @_;

my $domain;
if($recipient =~ /@(.*)>\s*$/)
{
$domain = $1;
}

#if(not defined $domain)
#{
# return(0, 513, 'Syntax error.');
#}
#els
if(grep $domain eq $_, @local_domains)
{
return(0, 554, "$recipient: Recipient address rejected: Relay access denied");
}

return(1);
}

sub queue_message
{
my($session, $data) = @_;

my $sender = $session->get_sender();
my @recipients = $session->get_recipients();
print $sender,"\n";

return(0, 554, 'Error: no valid recipients')
unless(@recipients);

my $msgid = add_queue($sender, \@recipients, $data)
or return(0);

return(1, 250, "message queued $msgid");
}