2

I run an Exim 4 mail server for friends and clients. We've just given our 8 year old son an email capable device and he uses this server for outbound and inbound email. All outbound email is sent authenticated.

I have a file called /etc/exim4/authenticated.users which contains username:password pairs. I have lines in my configuration like this:

  accept
    authenticated = *

  myserver_cram:
    driver = cram_md5
    public_name = CRAM-MD5
    server_secret = ${lookup{$1}lsearch{/etc/exim4/authenticated.users}{$value}fail}
    server_set_id = $1

What I would like is to have a file like this:

/etc/exim4/outgoing.copies littlejohnny:[email protected]

So that when someone authenticates to send an outgoing email as littlejohnny, a copy is sent to [email protected].

Does anyone know how to achieve this?

1 Answer 1

1

In your authenticator, you should have a line like server_set_id =. Whatever is on the right hand side of that line will be stored in a variable $authenticated_id. That variable can then be used in your routers to conditionally copy messages sent by your son's authenticated username.

It looks to me like you are using Debian, or a Debian derivative like Ubuntu. Please be aware that Debian packages the Exim configuration file in a way that is specific to their distribution. Because of this, it can be confusing to receive advice for generic exim systems and try to apply it to a Debian system. That said, if you really want it to work and you read the debian docs on how their packaging system works, you can make it work.

In case it's not obvious, I'm a non-Debian-Exim guy, so my advice is generic, you'll have to translate it to Debian's packaging standards.

First, you need to find the authenticators and make sure that they are using the server_set_id option. Here is an example authenticator:

auth_plain:
  driver = plaintext
  public_name = PLAIN
  server_condition = ${if eq {$3}{AUTH_STR}{yes}{no}}
  server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
  server_set_id = $auth2

Because of the vagaries of the different auth types, sometimes $auth1 will hold the username, sometimes it will be $auth2. If your system hasn't been updated for a while, you might also see $1 and $2, which were used before the auth-specific variables were added.

Now that you have the authenticated user's username being saved into $authenticated_id, you need to add a router that sends a copy of the mail to your address only if $authenticated_id matches your son's username. Because the order of routers matter, you'll want to add it pretty high in your routers to make sure you get everything, but you'll have to eyeball your own config to judge where exactly to put it.

Here's an example router that does what you want:

copy_jrs_mail:
  driver = redirect
  data = [email protected]
  condition = ${if eq{$authenticated_id}{littlejohnny}{yes}{no}}
  unseen

To do the same thing but look up the information from a file, you can actually drop the condition (because $authenticated_id being in the file will serve the same purpose) and change the data = portion to use a file:

copy_auth_mail:
  driver = redirect
  data = ${if exists{/etc/exim4/outgoing.copies}{\
         ${lookup{${lc:$authenticated_id}}lsearch{/etc/exim4/outgoing.copies}}}}
  unseen

Hopefully that gets you going in the right direction, good luck.

2
  • Can I use a lookup construct to get this from a file (as I have other parents on the server that may want to do the same thing when I tell them I've done this)? Any chance I could see how to do that? I'm a non-Exim guy, but I'm very impressed :-) Feb 10, 2011 at 8:30
  • Added an example stanza for a file lookup
    – jj33
    Feb 10, 2011 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .