Qmail Taps Extended

Problem

You're running qmail and you want to log as in "copy/archive/tap"  only the outgoing email messages.  Inter7, the creators of vpopmail have a nice solution in a patch named qmailtap.

This patch will actually give you the option to match a message's To and From addresses against a regexp and decide what to do with them, all in an easy to write configuration file but this solution will not differentiate between To and From so if any of them matches the regexp the messages will be copied.

If you would only want to log outgoing mail you could decide to log only the messages which have the From address set to a local account but since there's no way to know which of the From or To addresses  matched you can't do this.

Solution

I created another patch that would allow you to specify which address you want to match.

With the original patch to match everything To or From @domain.com and copy to copy@example.com  you would need a line like this in the configuration:

.*@domain.com:copy@example.com

With the new patch if you only want to log the messages with the From address @domain.com you would set the configuration like this:

F:.*@domain.com:copy@example.com

If you want to log only those with the To address @domain.com

T:.*@domain.com:copy@example.com

if you want the same behavior as the original patch:

A:.*@domain.com:copy@example.com

Note: When writing multiple rules you have to consider how qmail-queue works after this patch
For each message qmail-queue looks at the From address first and tries to match it against the lines
starting with F: or A:.   When it finds a match it copies the message and stops.
If it didn't find a match in the F: or A: lines  it will try to match the To address against
the T: and A: lines.

Download

If you have not applied qmailtap patch yet here is the new full patch:

Qmail taps Extended-full (10.46 KB)

If you have already applied the qmailtap patch here is a patch you have to apply to obtain the new functionality:

Qmail taps Extended-diff (3.54 KB)

Got any questions ? Or maybe you have other solutions... hit the comments!

12 thoughts on “Qmail Taps Extended

  1. Hi,

    Is it possible to to copy email if domain in not local, for example is my own domain is example.com, will it work as below

    T:!.*@example.com:copy@example.com

      1. Yes, every user in example domain will use this mail server for sending email, so I want to copy email if any user sends email outside example.com, if user sends within example.com then I do not need copy

  2. Hi,

    This two link are broken, can we have the correct link plz, or someone send me the second link, i have already qmail patched with qmail-tap.diff

    Thank’s

    1. The links are not broken, but if you try to download the patches with wget it will not work.
      This is because I have implemented a hotlink protection system on this blog.
      But if you just click the links they will work, you can either download the files or copy/paste the content of the patches.

  3. Hi,

    I just click the link and i have this error page:
    Sorry, no posts matched your criteria.

    I wondring if u can give me i link, where i have just to click, or send me this two files in my email plzzz

    Thank’s

  4. Hi,

    Me again,

    I juste patched with Qmail taps Extended-diff (3.54 KB) but it seems not to be working here is my syntax :
    F:.*@domain.com:copy@example.com

    I want to catch only the outgoing mail from domain.com in this Ex

    Any help will be apreciated

Leave a Reply