#!/usr/bin/perl # # Simple script to reject all incoming mail. # It is loosely based on a script by Allen Canning of Pencom SA. # # It should be run from inetd.conf with a line similar to: # # smtp stream tcp nowait root /path/to/script/mailbounce.pl mailbounce.pl # # I am undecided whether the EXPN command should be implemented (and always # return an error) or not implemented. In this version it is not implemented. # To change this, add it to the EHLO response and move it from the 502 command # set to the 550 set. # # Note that the VRFY command is implemented, but always returns an error, # because under RFC 5321 it is mandatory. (It was not mandatory under RFC 821, # was mandatory under RFC 1123, and is mandatory with an exception for security # reasons under RFC 2821 and RFC 5321.) # # Martin J Leese, September 1998 # E-mail: please@see.Web.for.e-mail.INVALID # Web: https://members.tripod.com/martin_leese/ # # # Change this to your mail hub my $mailhub = "your.mail.server"; # use Sys::Hostname; my $host = hostname(); # If the two lines above don't work for you then try: #use Sys::Hostname(); #my $host = hostname(); # my $CRLF = "\015\012"; # use FileHandle; STDOUT->autoflush(1); # # First we need our Greeting print STDOUT "220 $host does not accept mail. Try ${mailhub}$CRLF"; # # Main loop to receive mail while () { chomp; my ($command) = split; $command = uc $command; # if ($command =~ m/^QUIT$/) { print STDOUT "221 $host closing connection. Try ${mailhub}$CRLF"; last; # bail out of while loop } elsif ($command =~ m/^HELO$/) { print STDOUT "250 $host does not accept mail. Try ${mailhub}$CRLF"; } elsif ($command =~ m/^EHLO$/) { print STDOUT "250-$host does not accept mail. Try ${mailhub}$CRLF"; print STDOUT "250 HELP$CRLF"; } elsif ($command =~ m/^HELP$/) { print STDOUT "214-$host does not accept mail. Try ${mailhub}$CRLF"; print STDOUT "214-This is a dummy SMTP server that rejects all"; print STDOUT " incoming mail$CRLF"; print STDOUT "214-QUIT to close connection$CRLF"; print STDOUT "214 End of HELP info$CRLF"; } elsif ($command =~ m/^(MAIL|RSET|NOOP)$/) { # To accommodate broken SMTP servers, MAIL does not return an error print STDOUT "250 OK but I don't accept mail. Try ${mailhub}$CRLF"; } elsif ($command =~ m/^(RCPT|VRFY)$/) { # This error message is the one most likely to be returned to users print STDOUT "550 $host does not accept mail. Try ${mailhub}$CRLF"; } elsif ($command =~ m/^DATA$/) { # As RCPT commands are always rejected, this should never happen print STDOUT "503 Command out of sequence. Try ${mailhub}$CRLF"; } elsif ($command =~ m/^(EXPN|TURN|SEND|SOML|SAML)$/) { print STDOUT "502 Command not implemented. Try ${mailhub}$CRLF"; } else { print STDOUT "500 Command not recognised. Try ${mailhub}$CRLF"; } } # exit(0); # 0 = success