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

Q0429

Question

I would like to deliver mail addressed to a given domain to local mailboxes, but also to generate messages to the envelope senders.

Answer

You can do this with an unseen router and an autoreply transport, along the following lines:

# Router
auto_warning_r:
  driver = accept
  check_local_user
  domains = <domains you want to do this for>
  condition = ${if eq{$sender_address}{}{no}{yes}}
  transport = warning_t
  no_verify
  unseen

Place this router immediately before the normal localuser router. The unseen option means that the address is still passed on to the next router. The transport is configured like this:

# Transport
warning_t:
  driver = autoreply
  file = /usr/local/mail/warning.txt
  file_expand
  from = postmaster@your.domain
  to = $sender_address
  user = exim
  subject = Re: Your mail to $local_part@$domain

Note the use of the condition option to avoid attempting to send a message when there is no sender (that is, when the incoming message is a bounce message). You can of course extend this to include other conditions. If you want to log the sending of messages, you can add

log = /some/file

to the transport and also make use of the once option if you want to send only one message to each sender.


Clone this wiki locally