[exim] keep a local copy of all outbound emails, but only f…

Góra strony
Delete this message
Reply to this message
Autor: Florin Andrei
Data:  
Dla: Exim-users
Temat: [exim] keep a local copy of all outbound emails, but only for this sender domain
Background info:

This is a mail relay in the middle of the infrastructure, various
servers connect to it and ask it to kindly relay their email to various
destinations. No inbound email from Internet, most email is
software-generated (QA/testing environment, not production). *Most* (but
not all) email is intended for local (automated) consumption.

Routing logic currently implemented:

1. All emails with *sender* @otherdomain.com must be allowed to go on
the Internet. These are manually generated tests, very low volume.
Routing is handled beautifully with a single router at the top of the list.

2. Emails with *recipients* on a short list of a few @mydomain.com
addresses (specified in /etc/exim/mydomain_forwarded) must be relayed to
corporate inboxes at the office. This is mostly debug stuff I want to
see in my inbox.

3. Any *recipient* that matches local accounts must be delivered locally
to Dovecot IMAP, via dovecot_delivery

4. Everything else is blackholed, to prevent QA from spamming the Internet.

See config sample at the end.

What I need to add to the above is making a backup copy of all emails
with sender @otherdomain.com (see #1 on the list above) and either
deliver them locally to otheremail@localhost or relay them to
otheremail@???

I tried adding another router at the very top of the router list, either
a redirect router, or an acccept router with local delivery, or other
combinations. I get either delivery loops, or "Unrouteable address", or
"remote host address is the local host", or other failure modes. I am
obviously missing something simple.

E.g. this doesn't work:

otherdomain_backup:
driver = redirect
senders = *@otherdomain.com
file = /home/othermail/.forward
file_transport = address_file
unseen

How would you change the configuration listed below to keep a copy of
all emails routed by the first router? (and either deliver the copy
locally to dovecot_delivery or relay it to a neighbor server)

###############################################
begin routers

otherdomain:
driver = dnslookup
senders = *@otherdomain.com
transport = remote_smtp
no_more

system_aliases:
driver = redirect
allow_fail
allow_defer
data = ${lookup{$local_part}lsearch{/etc/aliases}}
file_transport = address_file
pipe_transport = address_pipe

userforward:
driver = redirect
check_local_user
file = $home/.forward
allow_filter
no_verify
no_expn
check_ancestor
pipe_transport = address_pipe
reply_transport = address_reply

procmail:
driver = accept
check_local_user
require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail
transport = procmail
no_verify

mydomain_users_forwarded_to_office:
driver = dnslookup
domains = mydomain.com
local_parts = /etc/exim/mydomain_forwarded
transport = remote_smtp

localuser:
driver = accept
check_local_user
transport = dovecot_delivery
cannot_route_message = Unknown user

drop_everything_else:
driver = redirect
domains = *
data = :blackhole:

begin transports

dovecot_delivery:
driver = pipe
command = /usr/libexec/dovecot/deliver
message_prefix =
message_suffix =
log_output
delivery_date_add
envelope_to_add
return_path_add
temp_errors = 64 : 69 : 70: 71 : 72 : 73 : 74 : 75 : 78
###############################################

--
Florin Andrei
http://florin.myip.org/