#!/usr/local/bin/perl

# Be nice to the web server and exit the process if a broken pipe,
# i.e. if the user jumps elsewhere or quits before the script has finished
sub sigpipe { exit; }
BEGIN { $SIG{'PIPE'} = 'sigpipe'; }

$| = 1;  # Turn off buffering of the output.

# Substitute this with your dictionary file
$dictfile = '/usr/share/lib/dict/words';

print <<EOT ;
Content-type: text/html


<HTML>
<HEAD>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<TITLE>Email addresses</TITLE>
</HEAD>
<BODY BGCOLOR="#ffcc33" TEXT="#0033cc">
<H3>Here are some email addresses you can try...</H3>
EOT

open(DICT,"<$dictfile") || die "\n";
my @dict = <DICT>;	# *slurp*
close DICT;
my $numdict = scalar @dict;

# Most .com addresses, cause spammers prefer those...
my @tops = (	'.com','.com','.com','.com','.com',
		'.es','.es','.es',
		'.net','.net','.net',
		'.org',
		'.us',
		'.co.uk',
		'.co.jp',
		'.com.au',
		'.com.sg',
		'.ru',  # Some faraway/slow domains are good.
		'.it',  # That way, more mailer daemons will have
		'.nl',  # time to bounce back while the spammers
		'.cz',  # are still connected.
		'.my',
		'.br',
		'.nz');
my $numtops = scalar @tops;

for (my $i=0;$i<2048;$i++) {
	my $user = $dict[int(rand $numdict)];
	chomp $user;
	my $host = '';
	if (rand() < 0.7) {
		$host = $dict[int(rand $numdict)];
		chomp $host;
		$host .= '.';
	}
	my $domain = $dict[int(rand $numdict)];
	chomp $domain;
	my $top  = $tops[int(rand $numtops)];
	print "<A HREF=\"mailto:$user\@$host$domain$top\">$user\@$host$domain$top</A><BR>\n";
}

print <<EOT ;
<H4>And don't forget these:</H4>
<P>
<A HREF="mailto:abuse@[127.0.0.1]">A friendly guy</A><BR>
<A HREF="mailto:postmaster@[127.0.0.1]">Another friendly guy</A></P>
</BODY>
</HTML>
EOT

exit 0;
