Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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).

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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:

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

    condition=${lookup mysql {\
            select email from vacation where \
                 email='${quote_mysql$local_part}@${quote_mysql:$domain}'\
                 and active='y'\
            }}
    no_expn
    transport=vacation_transport
    unseen
    no_verify

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:

vacation_transport:
    driver=autoreply
    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.

share|improve this answer
    
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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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