Add to Favourites Add to Favourites    Print this Article Print this Article

How to prevent bounce emails from leaving your server

Although this method isn't entirely correct in it's logic, as we do often want bounce messages to leave the system, if you don't, edit your /etc/system_filter.exim, and find this code:

if not first_delivery
then
   finish
endif

right *before* it, paste this code:

if $sender_address is ""
then
   if $header_Auto-Submitted: is not "auto-replied"
   then
       if ${lookup{${extract{2}{@}{$recipients}}}lsearch{/etc/virtual/domains}{yes}{no}} is "no"
       then
           noerror fail text "Delayed bounce message ignored"
           seen finish
       endif
   endif
endif



If you wish to get a copy of the dropped email, use this code instead:

if $sender_address is ""
then
   if $header_Auto-Submitted: is not "auto-replied"
   then
       if ${lookup{${extract{2}{@}{$recipients}}}lsearch{/etc/virtual/domains}{yes}{no}} is "no"
       then
           headers add "Old-Subject: $h_subject:"
           headers remove "Subject"
           headers add "Subject: [Delayed Bounce]$h_old-subject:"
           headers remove "Old-Subject"
           deliver "abuse@yourdomain.com"

           noerror fail text "Delayed bounce message ignored"
           seen finish
       endif
   endif
endif

Where you would replace abuse@yourdomain.com with the email you want.  It would be a good idea to use a local address here (that exists on this box), since if you forward it outbound, you're probably going to flag yourself for sending spam, which defeats the whole purpose of this guide.

This may help prevent backscatter, but has not been confirmed.

Referenced URL

Was this answer helpful?

Also Read