1

I've researched for an answer to this question and can't find anything.

I have Postfix running on Debian Stretch. I will soon be setting up Rspamd.

Here's the logic of what I want to have happen when spam arrives:

  • Postfix receives a message from the contact form on my website (via PHPMailer)
  • Postfix sends the message to Rspamd for processing
  • Rspamd flags the message as spam and adds appropriate headers
  • Postfix does NOT send the message to me@mydomain.net, but rather spam@mydomain.net

From what I gather, it seems that milters do not have this ability. How can this be accomplished?

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
pkSML
  • 143
  • 1
  • 7

1 Answers1

2

Postfix can check the headers set by the milter with milter_header_check. The postfix documentation also provides an example:

The following example sends all mail that is marked as SPAM to a spam handling machine. Note that matches are case-insensitive by default.

/etc/postfix/main.cf:
milter_header_checks = pcre:/etc/postfix/milter_header_checks

/etc/postfix/milter_header_checks:
/^X-SPAM-FLAG:\s+YES/ FILTER mysmtp:sanitizer.example.com:25

Just replace the FILTER action with REDIRECT spam@mydomain.net and it should work.
Cf. http://www.postfix.org/header_checks.5.html

stefan0xC
  • 216
  • 1
  • 5
  • Awesome Stefan! I have looked at the Postfix man pages, but have trouble understanding them. This was just the info I needed! – pkSML Apr 10 '18 at 12:41