Send all outgoing mail to /dev/null

Solution 1:

I did this on my development box by disabling sendmail completely and then having a simple perl script listen on the SMTP port and dump the emails into a directory. I'm sure it's possible to do with the sendmail configuration, but the perl script was much easier. Here's it stripped down to the essentials:

#!/usr/bin/perl -w 
use Net::SMTP::Server; 
use Net::SMTP::Server::Client; 

$server = new Net::SMTP::Server || 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
  open(MAIL,"> $filename") || die "$filename: $1"; 
  print(MAIL "$client->{MSG}\n"); 
  close(MAIL); 
} 

Solution 2:

The following sends everything to /dev/null:

LOCAL_RULE_0
R$* < @ $* > $*       $#local $: bit-bucket

This assumes that in your /etc/aliases:

bit-bucket: /dev/null