LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Screening Subject in sendmail not working (http://www.linuxquestions.org/questions/linux-server-73/screening-subject-in-sendmail-not-working-887449/)

vishesh 06-21-2011 12:50 AM

Screening Subject in sendmail not working
 
Hi members ,

I am trying to create a custom ruleset in sendmail, but not getting through, please guide me in right direction.

I made following entry in sendmail.mc

LOCAL_CONFIG
Kspamsubject hash /etc/mail/spamsubject
HSubject: $>ScreenSubject

LOCAL_RULESETS
SScreenSubject
----
----

TB0ne 06-21-2011 10:14 AM

Quote:

Originally Posted by vishesh (Post 4391376)
Hi members ,
I am trying to create a custom ruleset in sendmail, but not getting through, please guide me in right direction.

I made following entry in sendmail.mc
Code:

LOCAL_CONFIG
Kspamsubject hash /etc/mail/spamsubject
HSubject: $>ScreenSubject

LOCAL_RULESETS
SScreenSubject


And now if you actually tell us what you're trying to do, version/distro of Linux, and exactly WHAT is not working, and what error(s) you're seeing, we can perhaps help.

vishesh 07-11-2011 09:39 AM

Thanks for reply

I am using CentOS 5 and trying to block certain mails in sendmail depending on subject of mail

Thanks

bathory 07-13-2011 12:08 PM

Quote:

Originally Posted by vishesh (Post 4411655)
Thanks for reply

I am using CentOS 5 and trying to block certain mails in sendmail depending on subject of mail

Thanks

You don't need to mess with sendmail.cf.
If you use spamassassin or some other spam filtering software, you can create a custom rule to block mail based on the subject.
Or you can use procmail to filter mail based on subject. Create a ~/.procmalrc like this (replace <Offending subject> with the subject you want to filter out):
Code:

:0H:
* ^Subject:.*<Offending subject>
/dev/null

Regards

agentbuzz 07-14-2011 12:00 AM

Block spam subjects in sendmail config file?
 
While you shouldn't mess with sendmail.cf directly, you can just add the following to your sendmail.mc and then "./Build sendmail.cf" and "./Build install-cf":
Code:

#Rule to block subjects
F{SubBlockPat} /etc/mail/BAD-SUBJECTS
HSubject: $>Check_Subject
D{SubBlockMsg} Error
SCheck_Subject
R$* $={SubBlockPat} $* $#error $: 553 ${SubBlockMsg}

While you're mucking around with sendmail.mc, you should consider putting in a few blacklist lines:
Code:

FEATURE(`dnsbl', `dnsbl.njabl.org' `Rejected - see http://dnsbl.njabl.org/')
FEATURE(`dnsbl', `black.uribl.com' `Rejected - see http://www.uribl.com/')
FEATURE(`dnsbl', `sc.surbl.org' `Rejected - see http://www.surbl.org/')
FEATURE(`dnsbl', `zen.spamhaus.org', `Message from $&{client_addr}rejected see zen.spamhaus.org') dnl
FEATURE(`dnsbl', `dul.dnsbl.sorbs.net', `Message from $&{client_addr} rejected see dul.dnsbl.sorbs.net') dnl

You have to build the file "/etc/mail/BAD-SUBJECTS" with periods between character strings because a space is a token delimiter,

For more info, look at the knecht.mc file in sendmail-8.14.4/cf/cf, look at 4.3.3.1 and 4.3.3.5 in The Bat Book, or do this:
Code:

mail:~/Downloads/sendmail-8.14.4/doc/op$ GROFF_NO_SGR=1; export GROFF_NO_SGR
:~/Downloads/sendmail-8.14.4/doc/op$ make op.txt

vi op.txt and look for Define.Header. There is a section on the "H line" there.

You should know that blocking spam using "Subject:" line strings is like playing Whack-A-Mole at the state fair. As others have written here, use spamassassin. It has tons of plugins and there are community-based rules that you can fetch and experiment with.

TB0ne 07-14-2011 09:32 AM

Nice one, agentbuzz. Like alot of others, I do my filtering further downstream, but it's nice to have a solution that uses sendmail directives directly. There is a special dark art to configuring it. :)


All times are GMT -5. The time now is 09:04 AM.