1

I've set up a Linux server running Postfix that I'm using to send and relay emails, and one of the tasks that my mail server does is take incoming emails that are sent to specific addresses and forward them to email addresses that belong to another domain. I used this tutorial to set it up, and I've confirmed that the mail forwarding works as intended. However, some of the incoming emails have a confidentiality notice, and I want to strip those before forwarding the emails because the email address that the emails are forwarded to handles the emails differently based on the content of the body, and if the body contains the notice, the email will not be handled properly.

To give an example, I set up an alias called forwarding@example.com that sends email to an external address. I was then able to find and replace part of the confidentiality notice, but I am unable to replace it with an empty string, and I am unable to replace the entire notice. I added the following line in /etc/postfix/main.cf:

body_checks = pcre:/etc/postfix/body_checks

And the file `/etc/postfix/body_checks contains the following:

/CONFIDENTIALITY NOTICE:.*/ REPLACE ""
/Testing/ REPLACE ""

I'm able to send emails to forwarding@example.com, but instead of replacing the found strings with an empty space, the strings are replaced by the literal characters "". I've tried putting an empty space there instead, but when I do that I get the error warning: REPLACE action without text in body_checks map when I restart Postfix. I read the documentation, but could not find any examples of a string being replaced with an empty string. Does anyone know how to replace the found text with an empty string? Please let me know if you need any more information, and I'll be happy to provide it.

AndreasKralj
  • 331
  • 1
  • 6
  • 16

1 Answers1

1

You can use IGNORE:

IGNORE Delete  the  current  line  from the input, and inspect the next
       input line. See STRIP for an alternative that logs the action.

Example:

/CONFIDENTIALITY NOTICE:.*/ IGNORE
Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83