Add body_check to Proxmox MailGateway

Add body_check to Proxmox MailGateway

By default ProxmoxMG only scans the subject for bad words, but you can also enable body checks.

Step 1. First edit the main conf file and include in it the new file with body_check rules that We will add later:

nano /etc/postfix/main.cf

and to the end of the file add:

body_checks = regexp:/etc/postfix/body_checks
image 5 - Add body_check to Proxmox MailGateway

Step 2. Now create a new file body_checks and add rules to it:

nano /etc/postfix/body_checks

The format for each line in the body_checks file is as follows: /content_to_act_on/ ACTION

Regular expression checking with DISCARD and REJECT:

/free mortgage quote/     REJECT
/repair your credit/      REJECT
/cialix pills/            REJECT
/erectile/                DISCARD
/pussy/                   DISCARD
/viagra/                  DISCARD
/greekajob/               REJECT
  • DISCARD – The user will not receive any notification and his email will be discarded.
  • REJECT – The user will be notified that the content was rejected, example:
image 6 - Add body_check to Proxmox MailGateway

Step 3. Rebuild the index file:

postmap /etc/postfix/body_checks

Step 4. Restart Postfix to apply the rules:

service postfix restart

TIP: Postfix comes with regex support by default, but you can also install and use PCRE which is faster:

apt install postfix-pcre

and instead of regexp: use pcre: in /etc/postfix/main.cf


Source: https://www.postfix.org/BUILTIN_FILTER_README.html

whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.