I’ve recently migrated my hosting from one VPS to a new host. It was a lot more work than it should have been. I’ll try to be much better at keeping my host up to date and maintained.
At any rate, I finally have my mailserver up and running on the new host. I implemented greylisting and some other spam prevention measures. Sometimes I wonder what is being rejected and why. Here is a super simple perl one-liner that can look at the mail.log file and spit out what hosts are rejected, and what the rejection reasons are (independently.)
grep reject mail.log | perl -n -e ‘END { foreach my $key (sort {$hosts{$a} <=> $hosts{$b}} keys %hosts) { print “$hosts{$key}\t$key\n”; } foreach my $key ( sort { $reasons{$a} <=> $reasons{$b} } keys %reasons) { print “$reasons{$key}\t$key\n”;}} if (m/RCPT from (.*?): .*?: (.*);/) { $hosts{“$1”}++; $reasons{“$2”}++}’
Leave a Reply