Q0801

Nigel Metheringham edited this page Nov 29, 2012 · 2 revisions
Clone this wiki locally

Q0801

Question

How can I get Exim to strip the hostname from the sender's address?

Answer

If you set up a rewriting rule in the following form:

*@*.your.domain  $1@your.domain

then Exim will rewrite all addresses in the envelope and the headers, removing anything between @ and your.domain. This applies to all messages that Exim processes. If you want to rewrite sender addresses only, the the rule should be

*@*.your.domain  $1@your.domain  Ffrs

This applies the rule only to the envelope sender address and to the From:, Reply-to:, and Sender: headers.

The same rules can also be used if you want to ensure that the envelope sender is always set to the From: address. This is highly useful on a web hosting server where most people just install whatever programs they find and they don't use the -f or Return-path: headers to set the envelope sender. When they do this and a bounce occurs, the webmaster doesn't get the bounce mail, so they don't know that there is a problem. To fix this use:

*@*.your.domain  ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

This causes [user@host.domain.com](mailto:user@host.domain.com) to be replaced with their From: header. And if they've entered a full From address, then it will strip the e-mail from "User name" <user@domain>. This helps in tracking down the mail a lot, and makes sure that customer's get their bounces.