Dummy SMTP server

Решение автора JOTN, отсюда:

#!/usr/bin/perl -w
use Net::SMTP::Server;
use Net::SMTP::Server::Client;
 
$server = new Net::SMTP::Server('localhost', 25) || die("$!\n");
 
while($conn = $server->accept()) {
	my $client = new Net::SMTP::Server::Client($conn) ||
	die("Unable to handle client connection: $!\n");
	$client->process || next;
 
	# Here's where you can write it out or just dump it. Set $filename to
	# where you want to write it
	$filename = './collected_mail.txt';
	open(MAIL,">> $filename") || die "$filename: $1";
	print(MAIL "$client->{MSG}\n");
	close(MAIL);
}

/etc/ssmtp/ssmtp.conf:

root=postmaster
mailhub=localhost
#rewriteDomain=
hostname=localhost
FromLineOverride=YES

Под Ubuntu необходимые пакеты называются libnet-smtp-server-perl и ssmtp.