in reply to RE: Re: SMTP logging server
in thread SMTP logging server

i wrote this in 10 minutes
(here in italy is night and i've got a good bottle of wine in front of me ;)))
stupid as you whant but fools netscape messanger :)
I used NetServer::Generic since is too late for me to mess with sockets...
#!/usr/bin/perl -w use strict; use NetServer::Generic; my $server = new NetServer::Generic; $server->port(25); $server->callback(\&server); $server->timeout(25); ## random... $server->run(); sub server { open LOG, ">>/tmp/smtpd.log" || die "cannot open: $!"; print LOG "\nNew connection\n-------------\n"; print "220 mydomail.com ESMTP CianozMail 0.1 :)\n"; while(<STDIN>) { print LOG "$_"; if($_ =~ /^quit\r\n/i ) { print "221 Bye\n"; close LOG; return; } elsif($_ =~ /^data/i ) { ## read message body here... print "354 End data with <CR><LF>.<CR><LF>\n"; MESSAGE: while(my $line = <STDIN>) { if($line =~ /^\.\r\n/) { print "250 Ok: queued as ....\n"; last MESSAGE; } else { print LOG "$line"; } } } else { print "250 Ok\n"; #who cares? :-) } } }

Replies are listed 'Best First'.
RE: RE: RE: Re: SMTP logging server
by blogan (Monk) on Oct 19, 2000 at 04:21 UTC
    I think the original poster would rather be looking for the line: RCPT TO: youraddy@someplace.com And then just record the e-mail address here. This would just be one more branch in your code. Also, I'm a newbie, but shouldn't you be recording all the log information at one time? To prevent two clients from writing to the log at the same time.
      You are right, the code should also flock() the log file or a sentinel file and maybe do a lot more things off course... my code was just a trivial example...