---
name: "Mail::MtPolicyd::Plugin::Condition"
section: "3pm"
platform: "linux"
package: "mtpolicyd"
version: "2.05-1.2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Mail::MtPolicyd::Plugin::Condition"
---

# Mail::MtPolicyd::Plugin::Condition(3pm)

mtpolicyd plugin for conditions based on session values

## NAME

Mail::MtPolicyd::Plugin::Condition - mtpolicyd plugin for conditions based on session values

## VERSION

version 2.05

## DESCRIPTION

Will return an action, score or execute further plugins if the specified condition matched.

## PARAMETERS

- key (required)

  The name of the variable to check.

  Syntax is

  ```
    (<scope>:)?<variable-name>
  ```

  If no scope is give it defaults to request.

  Possible scopes are:

  - session, s

    Session variables.

  - request, r

    Request attribute variables.

  Examples:

  ```
    session:user_policy
    s:user_policy
    request:queue_id
    r:queue_id
    queue_id
  ```

At least one of the following parameters should be given or your condition will never match:

- match (default: empty)

  Simple string equal match.

- re\_match (default: empty)

  Match content of the session variable against an regex.

- lt\_match (default: empty)

  Match if numerical less than.

- gt\_match (default: empty)

  Match if numerical greater than.

- invert (default: 0)

  If set to 1 the logic will be inverted.

Finally an action must be specified.

First the score will be applied then the action will be executed or if specified additional plugins will be executed.

- action (default: empty)

  The action to return when the condition matched.

- score (default: empty)

  The score to add if the condition matched.

- Plugin (default: empty)

  Execute this plugins when the condition matched.

## EXAMPLE: use of postfix policy\_context

The policy\_context of postfix could be used to trigger checks in mtpolicyd.

To activate additional checks in mtpolicyd from within postfix use may use a configuration in postfix main.cf like:

```
  # check, no additional checks
  check_policy_service inet:localhost:12345
  ...
  # check with additional checks!
  check_policy_service { inet:localhost:12345, policy_context=strict_checks }
```

In mtpolicyd.conf:

```
  <Plugin if-strict-checks>
    module = "Condition"
    key = "policy_context"
    match = "strict_checks"
    <Plugin strict-check>
      # ...
    </Plugin>
    # more checks ...
  </Plugin>
```

The policy\_context feature will be available in postfix 3.1 and later.

If you need completely different checks consider using the vhost\_by\_policy\_context (mtpolicyd) option with different virtual hosts.

## EXAMPLE: execute postgrey action in postfix

If the session variable "greylisting" is "on" return the postfix action "postgrey":

```
  <Plugin trigger-greylisting>
    module = "Condition"
    key = "greylisting"
    match = "on"
    action = "postgrey"
  </Plugin>
```

The variable may be set by a UserConfig module like SqlUserConfig.

The postgrey action in postfix may look like:

```
  smtpd_restriction_classes = postgrey
  postgrey = check_policy_service inet:127.0.0.1:11023
```

## AUTHOR

Markus Benning \<ich@markusbenning.de\>

## COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by Markus Benning \<ich@markusbenning.de\>.

This is free software, licensed under:

```
  The GNU General Public License, Version 2, June 1991
```
