3

I followed this (https://workaround.org/ispmail/squeeze/big-picture) tutorial to set up my mailserver and it works very well.

I'd like to be able to reject email from certain users or if it contains certain strings or if the title matches something.

Is this possible?

I am using MySQL for users and am in a multidomain env.

Axel Latvala
  • 201
  • 1
  • 4
  • 12

1 Answers1

6

You can use header_checks and body_checks to block on certain strings. More info here. You can use smtpd_sender_restrictions to block mails from certain users. More info here.

#/etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header.re
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/blacklisted_roles

#/etc/postfix/header.re
/^Subject:(.*) offensive_word /     REJECT Inappropriate word

#/etc/postfix/blacklisted_roles
spammer@domain.tld    REJECT
clement
  • 955
  • 5
  • 9
  • Sounds cool! Gotta try it. Am I able to route "rejected" mail to the receptors "spam" folder? Or does this just automatically discard everything? – Axel Latvala Mar 02 '14 at 11:41
  • The mail would be discarded and you can't able to route those messages. I would recommend to use SpamAssassin instead – ALex_hha Mar 02 '14 at 12:11
  • @ALex_hha is right. If you want all those mails to land in Spam, Do these checks in Spamassassin Add custom headers/rewrite default Spamassassin headers and use them in your global sieve rules on dovecot side. – clement Mar 02 '14 at 12:19
  • How do I configure spamasassin (AMaViS?) to do this? – Axel Latvala Mar 04 '14 at 21:57
  • http://spamassassin.apache.org/full/3.1.x/doc/Mail_SpamAssassin_Conf.html should help – clement Mar 05 '14 at 07:32