2010-09-22:
Rewriting reply-to in exim4 on Ubuntu

I receive email from many places, such as from home and work, and all of it gets piped through my mail server into one box, and then all my outgoing mail comes from the same address.

My work wanted me to use my work address any time I sent work email, which doesn't work with my 'one email box' solution.

The solution is to rewrite the reply-to: field whenever I send email to anyone at my work domain. This is evidently easy to do on Postfix, but I'm using exim4. exim4 has all these ways to rewrite addresses based on rules - unfortunately you can't rewrite one address (the reply-to) based on other addresses (the to/cc fields).

Turns out the answer is to use an exim4 system wide filter by creating a file:

# Exim filter          << THIS LINE REQUIRED

# Rewrite my reply-to for any mail going to work
if
	"$header_to:, $h_cc:" contains "@the.place.that.I.work.com" and
	$header_from: contains "dave@"
then
	headers remove "Reply-To"
	headers add "Reply-To: dave@the.place.that.I.work.com"
endif

And then I add this line to my exim config (I'm using flat file, evidently, so I added it near the top of /etc/exim4/exim4.conf.template):

system_filter = /etc/exim4/the-filter-file-saved-here

And the last I do is restart exim4:

/etc/init.d/exim4 restart


Back to Solutions.

DaveSource.com - Dave's geek site GetDave.com - all the current Dave Pointers. MarginalHacks - I have an elegant script for that, but it's too small to fit in the margin.