1# System command filter23This module executes an arbitrary system command during a specified stage of4checks execution.56```7command executable_name arg0 arg1 ... {8 run_on body910 code 1 reject11 code 2 quarantine12}13```1415## Arguments1617The module arguments specify the command to run. If the first argument is not18an absolute path, it is looked up in the Libexec Directory (/usr/lib/maddy on19Linux) and in $PATH (in that ordering). Note that no additional handling20of arguments is done, especially, the command is executed directly, not via the21system shell.2223There is a set of special strings that are replaced with the corresponding24message-specific values:2526- `{source_ip}` – IPv4/IPv6 address of the sending MTA.27- `{source_host}` – Hostname of the sending MTA, from the HELO/EHLO command.28- `{source_rdns}` – PTR record of the sending MTA IP address.29- `{msg_id}` – Internal message identifier. Unique for each delivery.30- `{auth_user}` – Client username, if authenticated using SASL PLAIN31- `{sender}` – Message sender address, as specified in the MAIL FROM SMTP command.32- `{rcpts}` – List of accepted recipient addresses, including the currently handled33 one.34- `{address}` – Currently handled address. This is a recipient address if the command35 is called during RCPT TO command handling (`run_on rcpt`) or a sender36 address if the command is called during MAIL FROM command handling (`run_on37 sender`).3839If value is undefined (e.g. `{source_ip}` for a message accepted over a Unix40socket) or unavailable (the command is executed too early), the placeholder41is replaced with an empty string. Note that it can not remove the argument.42E.g. `-i {source_ip}` will not become just `-i`, it will be `-i ""`4344Undefined placeholders are not replaced.4546## Command stdout4748The command stdout must be either empty or contain a valid RFC 5322 header.49If it contains a byte stream that does not look a valid header, the message50will be rejected with a temporary error.5152The header from stdout will be **prepended** to the message header.5354## Configuration directives5556### run_on `conn` | `sender` | `rcpt` | `body`57Default: `body`5859When to run the command. This directive also affects the information visible60for the message.6162- `conn`<br>63 Run before the sender address (MAIL FROM) is handled.<br>64 **Stdin**: Empty <br>65 **Available placeholders**: {source_ip}, {source_host}, {msg_id}, {auth_user}.6667- `sender`<br>68 Run during sender address (MAIL FROM) handling.<br>69 **Stdin**: Empty <br>70 **Available placeholders**: conn placeholders + {sender}, {address}.71 The {address} placeholder contains the MAIL FROM address.7273- `rcpt`<br>74 Run during recipient address (RCPT TO) handling. The command is executed75 once for each RCPT TO command, even if the same recipient is specified76 multiple times.<br>77 **Stdin**: Empty <br>78 **Available placeholders**: sender placeholders + {rcpts}.79 The {address} placeholder contains the recipient address.8081- `body`<br>82 Run during message body handling.<br>83 **Stdin**: The message header + body <br>84 **Available placeholders**: all except for {address}.8586---8788### code _integer_ ignore <br>code _integer_ quarantine <br>code _integer_ reject _smtp-code_ _smtp-enhanced-code_ _smtp-message_8990This directive specifies the mapping from the command exit code _integer_ to91the message pipeline action.9293Two codes are defined implicitly, exit code 1 causes the message to be rejected94with a permanent error, exit code 2 causes the message to be quarantined. Both95actions can be overridden using the 'code' directive.96