Exim regex: Capture all VERPed emails with a given header pattern

Consider your VERP generater produces a Return-Path header of the form:
and you want a router to capture all bounce emails having this/similar as the To header. This router can serve multiple purpose like – feeding to a bounce processor, silently killing all bounces ( not intended ) or POSTing the email to an API.
Suppose you have a router named bounceprocessor that HTTP POST to an API named bouncehandler at localhost/api.php, we will design the Regex as:

begin routers

	driver = pipe
	domains = +local_domains
	condition = ${if match{$local_part}{^bounces-\w+-\w+-\w+-\w+$}{true}{false}}
	command = /usr/bin/curl "action=bouncehandler" --data-urlencode "email@-" http://localhost/api.php
	user = nobody
	group = nogroup

Please note that

\w = words 
\d = digits 

Thanks to Mark Bergsma and Jeff Green for helping me with the regex.


Altering e-mail ‘Return-Path’ with exim4 and PHP mailer in Wikitech Labs

While implementing VERP, I always found that the ‘Return-Path’ address of any send email — was getting rewritten to root@wikimedia.org. This was frustrating as I had already changed the $header['Return-Path'] many times in the UserMailer.php and the result was just this one.
* Rewrite custom generated Return-Path to email-headers while sending
* Implement VERP addressing to handle bounces
*The PHP part:
+ Make sure the UserMailer.php ( or anyother file that sends the mail ) have custom header configurations such as:

$headers[ ‘Return-Path’ ] = ‘return-to-here@domain’ ;
mail( $to, $sub, $body, $headers );
*Now, the exim4 part:
+ Open your sudo nano /etc/exim4/exim4.conf and add the following line to the main configuration area:
( optional )

# Return Path
return_path_remove = false 

+ Remove the line errors_to from the desired router (( here wiki_mail router )

driver = manualroute
condition = ${if eqi{$header_X-Mailer:}{MediaWiki mailer}}
errors_to = ${if def:h_return-path: {${address:$h_return-path:}} fail}
headers_remove = return-path
transport = remote_smtp
route_list = *     

Yay! all done. Now, $ sudo /etc/init.d/exim4 restart
Now test it by sending a mail to some remote id, using Special:EmailUser
PS: There is a shorter version, with just removing the errors_to from the wiki_mail router.