Spamcheck.py is a python script that was designed enable mail filtering using postfix, spamassassin (spamd), and lmtp. It recieves an email via a content filter from postfix, runs it through spamd, and rewrites the recipient address if it is spam. Because it is designed to use lmtp, all mailboxes must be local.
The attached is a modified spamcheck.py (renamed to spamgate.py to prevent confusion) for use on a gateway postfix mta, with no local mailboxes. ok, here are the details. The attached spamgate.py has been modified in the follwoing ways. 1) lmtp delivery has been replaced by smtp delivery. (by Tony Hoyle) This happens like this: a) Mail is recieved by postfix smtpd running on port 25. This stmpd has a content filter applied like this: main.cf: content_filter = spamgate master.cf: spamgate unix - n n - - pipe flags=R user=filter argv=/usr/local/bin/spamgate.py -s${sender} -r${recipient} -llocalhost:10025 b) After spamgate.py completes processing on the mail (I will cover the details of what this processing entails later) spamcheck sends the mail back to postfix running another smtpd on a different port (10025 in this example) with NO content filter. This smtpd is configured to accept connections from localhost only, so it can't be used by spammers to bypass your content filter. It could, however, be configured to be used by your internal mail servers to allow outbound mail to bypass the filters. This stmpd is configured like this: master.cf: 10025 inet n - n - - smtpd -o content_filter= -o local_recipient_maps= -o smtpd_helo_restrictions= -o smtpd_client_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 2) I added the following modifications to Tony's version: a) Changed the recipient variable to be a list (reciplist). It now works for emails with more that one recipient. b) Changed the way spamcheck checks SA's output. It used to just check for X-Spam-Status: yes. I now have it checking the X-Spam-Level. This allows you to set one threshold in SA for marking spam, and another (higher) level in spamcheck for redirecting spam to a spamtrap. To adjust this level, modify the line that reads: spam_pat = re.compile(r'^X-Spam-Level:\s+\*\*\*\*\*\*\*\*\*\*') You can add or subtract '\*' to adjust the level. It is set to 10 now. 3) Don't forget to modify the line that defines the spamtrap email address: new_reciplist[0] = '[EMAIL PROTECTED]' I hope that this is helpful. -----Original Message----- From: James Sizemore [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 06, 2002 2:44 AM To: Steve Halligan Subject: Re: [SAtalk] There has to be a way. That would be great. Steve Halligan wrote: I have a changed spamcheck.py python script that does this for me. I can get you a copy of it. -----Original Message----- From: James Sizemore [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 05, 2002 11:50 PM Cc: [EMAIL PROTECTED] Subject: [SAtalk] There has to be a way. I use Spamassassin site wide (using Postfix and transports) This works great, I had a request from one of the domains that go through my mail server to have all tagged mail go to a single account. I have look around and could not find a way to make postfix do this. So using anything anywhere. can this be done. I hope I have an option other then writing a mail proxy to scan each mail for the tag, and then rewrite the "To:"? field. Thanks. -- [][][][][][][][][][][][][][][][][][][][][][][][] [] James O Sizemore III [] [] [EMAIL PROTECTED] [] [] [EMAIL PROTECTED] [] [] ISDN-NET Network Operations [] [][][][][][][][][][][][][][][][][][][][][][][][] ------------------------------------------------------- This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en _______________________________________________ Spamassassin-talk mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/spamassassin-talk -- [][][][][][][][][][][][][][][][][][][][][][][][] [] James O Sizemore III [] [] [EMAIL PROTECTED] [] [] [EMAIL PROTECTED] [] [] ISDN-NET Network Operations [] [][][][][][][][][][][][][][][][][][][][][][][][]
spamgate.py
Description: Binary data