Blocking empty subject line emails from being sent or received?
How can I configure Postfix, Dovecot, and/or SpamAssasin to reject all incoming and outgoing emails with empty subject line emails?
I am running on a Debian 8.6.
If you want to REJECT the mail, which would be a good idea as it also informs the sender that you don't want to receive mail with empty subject, you should use Postfix header_checks.
Add header_checks = pcre:/etc/postfix/header_checks
to your main.conf
and then add there this regular expression for empty Subject:
/^subject: *$/ REJECT Please add subject to your mail.
In order to use this Perl Compatible Regular Expression you must have Postfix PCRE map support (from package postfix-pcre
) installed.
Only limitation with header_checks
is that it cannot recognize if the Subject
field is totally missing. This problem you could address by scoring it higher on SpamAssassin. For global configuration /etc/spamassassin/local.cf
and for user configuration ~/.spamassassin/user_prefs
add:
score MISSING_SUBJECT 30
If you need to REJECT mails without Subject
header, not just flag and/or quietly remove the mail, you can make SpamAssasin reject mail based on score by using it as a proxy-filter for Postfix.