| [FrontPage] [TitleIndex] [WordIndex]

# TmdaPostfixPolicy

The Postfix MTA has the ability to invoke external policy services to determine what to do with an incoming email. The advantage of this approach is that the MTA can evaluate how to dispose the email while the sending server is connected. Because the envelope sender address can be forged, this can reduce the impact of sending a bounce or message delivery error to the wrong address.

With that in mind, I created a simplistic Postfix policy service which queries TMDA to determine what to do. The code below is an initial trial, which has some caveats:

- It only works on filter rules that result in a bounce. It currently ignores things like ACTION_INCOMING, ACTION_FAIL_* and ACTION_EXPIRED_DATED.
- It has external dependancies: grep, cut, logger
- It's not written in python so it's integration with TMDA is limited to the features of external TMDA programs
- It only works with the "bounce" TMDA action. Ideally, it would work with the confirm action, but unfortunately, SMTP doesn't allow for sufficient space to specify a confirmation request in a 550 bounce error message. There may be enough space to specify a URL for which could be used for confirmation.

Here's how you install this policy daemon:

1. Make sure that you've set "ALLOW_MODE_640 = True" in /etc/tmdarc
2. Make sure that all users .tmda/config and .tmda/crypt_key have their group set to "mail" and have 640 permissions
3. Copy the code (see below) into /usr/local/src/tmda/contrib/tmda-postfix-policy.sh
4. Add the following to master.cf:

       tmda    unix  -       n       n       -       -       spawn
           user=mail argv=/bin/bash /usr/local/src/tmda/contrib/tmda-postfix-policy.sh

5. Add the following to main.cf:

       smtpd_recipient_restrictions =
               permit_mynetworks,
               check_policy_service unix:private/tmda

   Alternatively, you can add it to "smtpd_data_restrictions" or "smtpd_end_of_data_restrictions".
6. Restart Postfix

This is the code that implements this: tmda-postfix-policy.sh

- [get | view] (1.7 KB) attachment:tmda-postfix-policy.sh

2007-07-30 15:45