#!/usr/bin/perl -w # # fake-pop3 # John Simpson 2008-08-30 # # simple implementation of POP3 server (defined in RFC 1939) which # - accepts ANY authentication attempt # - presents the client with what appears to be an empty mailbox # ############################################################################### # # Copyright (C) 2008 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### require 5.003 ; use strict ; my $state = 0 ; # 0=authentication, 1=transaction print "+OK fake-pop3\r\n" ; while ( 1 ) { chomp ( my $input = <> ) ; my @w = split ( /\s+/ , $input ) ; my $cmd = uc shift @w ; if ( $cmd eq "QUIT" ) { print "+OK goodbye\r\n" ; exit 0 ; } elsif ( ( $cmd eq "USER" ) || ( $cmd eq "PASS" ) || ( $cmd eq "APOP" ) ) { print "+OK fake pop3 session, credentials are ignored\r\n" ; } elsif ( $cmd eq "STAT" ) { print "+OK 0 0\r\n" ; } elsif ( ( $cmd eq "LIST" ) || ( $cmd eq "UIDL" ) ) { my $n = shift @w ; print defined ( $n ) ? "-ERR no such message\r\n" : "+OK\r\n.\r\n" ; } elsif ( ( $cmd eq "RETR" ) || ( $cmd eq "DELE" ) || ( $cmd eq "TOP" ) ) { print "-ERR no such message\r\n" ; } elsif ( ( $cmd eq "NOOP" ) || ( $cmd eq "RSET" ) ) { print "+OK\r\n" ; } else { print "-ERR unknown command\r\n" ; } }