#!/usr/bin/perl
#	@(#) fakepop.pl
#
# $Source: $
# $Revision: $
# $Date: $

if (!open(F, ">>/var/log/fakepop.log")) {
	print "-ERR Unable to open logfile\n";
	exit(2);
}

select(F); $| = 1; select(STDOUT); $| = 1;
$a = localtime(time);
print F "\n$a\n";

# Start
print "+OK Fake POP3 server ready\r\n";

while (<STDIN>) {
	if (length($_) >= 80) {
		next;
	}

	if (/^pass /i) {
		print "+OK Mailbox open, 0 messages\r\n";
		next;
	}

	print F "Cmd: $_";

	if (/^user /i) {
		print "+OK Send me your password, as if I care\r\n";
		next;
	}
	if (/^list/i) {
		print "+OK Mailbox scan listing follows\r\n.\r\n";
		next;
	}
	if (/^retr/i) {
		print "-ERR No such message\r\n";
		next;
	}
	if (/^stat/i) {
		print "+OK 0 0\r\n";
		next;
	}
	if (/^quit/i) {
		print "+OK Try again later\r\n";
		exit(0);
	}
	print "-ERR I don't know that one\r\n";
}

exit(0);
