# Sample Configuration for Experimental Return Path Rewriting in Exim 3 # Copyright 2004, Daniel Roethlisberger # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # copy of the GNU General Public License is distributed with exim itself ############################################################################## ### Version 1 of my return path rewriting scheme ### Obsoleted by http://www.roe.ch/spam/rpr-exim3-roe-02.txt ### See http://www.roe.ch/spam/return-path-rewriting.xml # Q() : Quoting s/([=%#_])/_\1/g # H() : Hash (MD5) # local_user : local part of original recipient address, # or full recipient (s/@/%/) address if nonlocal # local_domain : domain of original recipient (which is a local domain) # old_from : original return path / envelope sender (s/@/#/) # secret : local RPR secret # timestamp = strftime(%Y%m%d%H%M) # authdata = $secret + $timestamp + '=' + Q($old_from) + '=' + $local_user # new_from = 'bouce-' + H($authdata) + '-' + $authdata + # '@' + $local_domain ############################################################################## ### in startup.pl use POSIX qw(mktime); ### [...] sub rpr_verify_date { my ($y, $m, $d, $ru, $rd) = @_; # 1296000 = 15 * 24 * 60 * 60 = 15d if(time() <= 1296000 + mktime(0, 0, 0, $d, $m-1, $y-1900)) { return $ru.'@'.$rd; } else { return 'postmaster@'.Exim::expand_string('$domain'); } } ############################################################################## ############################################################################## ### in exim.conf ### somewhere near the top - ADJUST THIS !!! # the secret RPR_SECRET = yoursecret RPR_URL = http://www.roe.ch/spam/return-path-rewriting.xml # domain lists or file lookups or the like -- gets used in "senders =" below # to decide whether the router is run on a foreign address or not. # You may want to edit the senders line below instead of adding these macros. LOCAL_DOMAINS = your : local : domains VIRTUAL_DOMAINS = your : virtual : domains ### [...] ### in the directors section, preferrably at the top # Return Path Rewriting # rewrite incoming RPR bounces to their real destinations rpr_return: driver = smartuser prefix = bounce- condition = ${if and {{eq {$sender_address}{}}\ {match {$local_part}{^([0-9a-f]\{32\})-(\\d\{8\}(?:\\d\{4\})?=(?:.*[^_])?(?:_[_#])*#[^=#]+=.+)\$}}\ {eq {${md5:RPR_SECRET-$2@$domain}}{$1}}\ } {1}{0}} new_address = ${if match {$local_part}{^[0-9a-f]\{32\}-(\\d\{4\})(\\d\{2\})(\\d\{2\})(?:\\d\{4\})?=((?:.*[^_])?(?:_[_#])*)#([^=#]+)=(.+)\$}{\ ${sg {${perl{rpr_verify_date}{$1}{$2}{$3}{$4}{$5}}} {_([_=#%])}{\$1}}\ }{"postmaster@$domain"}} headers_add = "X-RPR-Return: DSN routed to destination via $primary_hostname\n\ \tSee RPR_URL" rpr_error_checksum: driver = smartuser prefix = bounce- condition = ${if and {{eq {$sender_address}{}}\ {match {$local_part}{^([0-9a-f]\{32\})-(\\d\{8\}(?:\\d\{4\})?=(?:.*[^_])?(?:_[_#])*#[^=#]+=.+)\$}}\ } {1}{0}} new_address = "postmaster@$domain" headers_add = "X-RPR-Alert: Checksum mismatch!" rpr_error_nodsn: driver = smartuser prefix = bounce- condition = ${if match {$local_part}{^([0-9a-f]\{32\})-(\\d\{8\}(?:\\d\{4\})?=(?:.*[^_])?(?:_[_#])*#[^=#]+=.+)\$} {1}{0}} new_address = "postmaster@$domain" headers_add = "X-RPR-Alert: Not a DSN (non-empty return-path)!" ### [...] ### in the routers section, preferrably at the top # Return Path Rewriting # rewrite outgoing mail with foreign return-path to local RPR scheme rpr_lookup_mx: senders = !LOCAL_DOMAINS:!VIRTUAL_DOMAINS driver = lookuphost transport = remote_smtp ignore_target_hosts = 127.0.0.0/8 condition = ${if and {{!eq {$sender_address}{}}\ {!match {$h_X-RPR-Return:}{$primary_hostname}}\ }{1}{0}} headers_add = "X-RPR-Rewrite: SMTP envelope sender rewritten by $primary_hostname\n\ \tSee RPR_URL" errors_to = "${quote:bounce-\ ${md5:\ RPR_SECRET-\ ${sg {$tod_log}{^(\\\\d+)-(\\\\d+)-(\\\\d+) (\\\\d+):(\\\\d+):(\\\\d+)}{\\$1\\$2\\$3\\$4\\$5}}=\ ${sg {${sg {$sender_address}{([=#%_])}{_\\$1}}}{@}{#}}=\ ${sg {$original_local_part}{([=#%_])}{_\\$1}}\ ${if eq {$domain}{$original_domain}\ {%$original_domain@$primary_hostname}\ {@$original_domain}\ }\ }-\ ${sg {$tod_log}{^(\\\\d+)-(\\\\d+)-(\\\\d+) (\\\\d+):(\\\\d+):(\\\\d+)}{\\$1\\$2\\$3\\$4\\$5}}=\ ${sg {${sg {$sender_address}{([=#%_])}{_\\$1}}}{@}{#}}=\ ${sg {$original_local_part}{([=#%_])}{_\\$1}}\ ${if eq {$domain}{$original_domain} {%$original_domain}{}}\ }@${if eq {$domain}{$original_domain} {$primary_hostname}{$original_domain}}" ##############################################################################