4

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

2 Answers 2

6

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.

1
  • That's one awesome and explicit answer ! Dec 23, 2010 at 12:30
0

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

3
  • Of course. But i wanted to personalize the notice message as "You may contact Mr. X now at [email protected]."
    – PeterMmm
    Dec 23, 2010 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, 2010 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, 2010 at 10:17

You must log in to answer this question.

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