#!/usr/bin/perl # Simple perl script to reject email at the SMTP level. # Please send any comments, etc to the author, pb@cl.cam.ac.uk # Collect the supplied args, hostname and date $info = join(" ", @ARGV); undef(@ARGV); chop($host = `uname -n || hostname`); chop($date = `date`); $msg = "All email should be sent to user\@cl.cam.ac.uk and NOT to a specific machine"; $| = 1; # do not buffer IO print "220 $host SMTP email rejecter ready at $date.$info\r\n"; while (<>) { last if /^quit/i; if (/^hel[op]/i) { print "250 $host Hello there - I shall reject all mail you send\r\n"; } elsif (/^mail *from:/i) { print "250 I accept any sender address but I shall reject all email\r\n"; } elsif (/^rcpt *to:[ ]*([^\n\r]*)/i) { print "550 $msg (e.g. $1)\r\n"; } elsif (/^vrfy/i || /^expn/i) { print "550 $msg\r\n"; } elsif (/^data/i) { print "503 No recipeints are ever valid\r\n"; } elsif (/^rset/i | /^noop/i | /^debug/i) { print "250 OK\r\n"; } else { print "500 Command unrecognized.\r\n"; } } print "221 $host closing connection. Goodbye.\r\n";