Running exim4 i cannot figure out how to send a notice message to the sender, if a certain address gets mail (the address of the user that will left the company).


You can use the "autoreply" driver to send automated reply messages. It is normally used for vacation messages, but it is of course capable of sending back any kind of mail.

Roughly, what you need is a router, which (depending on some condition) redirects the message to the transport using the autoreply driver. The router is something like this:

    domains = +local_domains
    senders = ! ^.*-request@.*:\
            ! ^bounce-.*@.*:\
            ! ^.*-bounce@.*:\
            ! ^owner-.*@.*:\
            ! ^postmaster@.*:\
            ! ^webmaster@.*:\
            ! ^listmaster@.*:\
            ! ^mailer-daemon@.*:\
            ! ^root@.*:\
            ! ^noreply@.*

    condition=${lookup mysql {\
            select email from vacation where \
                 and active='y'\

The router above is a snippet about vacation, again, but you should have no problem rewriting this. Also, it uses mysql as a backend, so your config will be slightly different if you use files for example, but you get the idea...

Having the router, you need a transport (in this example, it is called "vacation_transport"), which is something like this:

    from= ${lookup mysql {\
            select concat('"',name,'" <',username,'>') \
            from mailbox where username='${local_part}@${domain}' AND active=1 \
    to= ${lookup mysql {\
            select '${quote_mysql:$sender_address}' \
            from vacation where email='${local_part}@${domain}' and active='y' \

    subject= ${lookup mysql {\
                    select subject from vacation \
                    where email='${local_part}@${domain}' and active='y' \

    text= ${lookup mysql {\
            select body from vacation \
            where email='${local_part}@${domain}' and active='y' \

Again, it is using a mysql backend (it is a copy-paste from the same config file, ofcoz). The point is to set the "from", "to", "subject" and "text" variables. The autoreply transport will use these to compose the reply mail. If you need to notify the sender about the user's absence, you can remove the lookups, and for the most part you can include a static text. Again, this example is about vacation mails, where the user can customize his/her message.

See this page about the autoreply driver: http://wiki.exim.org/EximAutoReply

Also, the exim documentation is useful as well.

  • That's one awesome and explicit answer ! – Antoine Benkemoun Dec 23 '10 at 12:30

I would assume that when you delete the mailbox it will send a bounce back saying that the mailbox doesn't exist.

  • Of course. But i wanted to personalize the notice message as "You may contact Mr. X now at x@example.com." – PeterMmm Dec 23 '10 at 9:43
  • I don't know that mail server package but normally companies wouldn't do that. You typically don't want customers or vendors being redirected to another company. – mrdenny Dec 23 '10 at 9:58
  • Senders will be informed for certain time with a personal e-mail address. They do not work anymore here, but they're still alive. – PeterMmm Dec 23 '10 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.