Skip to content
Nigel Metheringham edited this page Nov 30, 2012 · 3 revisions

Q1502

Question

How can I get Exim to handle bang path addresses?

Answer

In general, you can't (Exim is an Internet mailer and recognizes only RFC 2822 domain-style addresses) but some restricted kinds of bang path can be dealt with by appropriate rewriting - but please note the warning below. Exim treats a bang path address as an unqualified local part, and so will qualify it with your domain. A rule such as

\N^([^!]+)!(.+)@your\.domain$\N   $2@$1

turns *a!b@your.domain into b@a. You can also use a repeating rule to turn multi-component paths into the percent hack notation with a rule such as

\N^([^!]+)!([^@%]+)(.+)$\N   $2%$1$3   R

which turns a!b@c into b%a@c and a!b!c@d first into b!c%a@d and then, because of the R flag, into c%b%a@d. The R flag causes repetition up to 10 times. Warning: If you install a general rewriting rule like the above, you are opening yourself up to the possibility of unwanted relaying. A host that is not permitted to relay through your system could send a message with an SMTP command line such as

RCPT TO:<victim-host!victim-user@your.domain>

and this would be accepted because it is addressed to your domain. However, the rewriting then converts the address, and the message does in fact get relayed. One way round this, if all your bang path messages are passed to Exim via SMTP, is to use the S rewriting flag. This applies a rewriting rule to incoming SMTP addresses as soon as they are received, before checking for qualification, relaying, etc. So a rule such as

\N^([^!]+)!(.+)$\N  $2@$1  S

rewrites simple two-component bang paths before the result is checked for relaying. However, this does not rewrite addresses in the headers of the message.


Clone this wiki locally