LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-04-2011, 04:36 AM   #1
Emil M
LQ Newbie
 
Registered: Feb 2010
Posts: 25

Rep: Reputation: 0
[SOLVED] Postfix mail filter


I have a Debian server with Postfix and would like to know if it's possible to create some "manual" filters, move/reject mails if the body contains something, if the header does and if it's sent to a specific person etc? Maybe coupling it with mysql

Last edited by Emil M; 10-18-2011 at 05:00 AM.
 
Old 10-04-2011, 08:50 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by Emil M View Post
I have a Debian server with Postfix and would like to know if it's possible to create some "manual" filters, move/reject mails if the body contains something, if the header does and if it's sent to a specific person etc? Maybe coupling it with mysql
Since you're using Postfix, you should look into spamassasin.
http://spamassassin.apache.org/

Configs for it are in plain text, so it should be easy to put in whatever rule(s) you're looking for, and disable the ones you don't want.
 
1 members found this post helpful.
Old 10-04-2011, 09:23 AM   #3
Emil M
LQ Newbie
 
Registered: Feb 2010
Posts: 25

Original Poster
Rep: Reputation: 0
I can see that this might fit my needs
http://svn.apache.org/repos/asf/spam...3.3/sql/README


Do you know how to enable spamassassin for Postfix and to check if it's working properly?
 
Old 10-04-2011, 09:30 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by Emil M View Post
I can see that this might fit my needs
http://svn.apache.org/repos/asf/spam...3.3/sql/README

Do you know how to enable spamassassin for Postfix and to check if it's working properly?
There are many how-tos you can find on Google. Some are even linked from the Postfix website:
http://www.postfix.org/docs.html
http://www.akadia.com/services/postf...massassin.html
 
1 members found this post helpful.
Old 10-05-2011, 03:20 AM   #5
Emil M
LQ Newbie
 
Registered: Feb 2010
Posts: 25

Original Poster
Rep: Reputation: 0
Thanks. I've configured Spamassassin now (without MySQL for now), but I'm facing some issues which restricts me from sending and receiving mails:


Code:
Oct  5 10:15:39 *** postfix/smtpd[20357]: fatal: open database /etc/postfix/access_client.db: No such file or directory
Oct  5 10:15:40 *** postfix/master[20259]: warning: process /usr/lib/postfix/smtpd pid 20357 exit status 1
Oct  5 10:15:40 *** postfix/master[20259]: warning: /usr/lib/postfix/smtpd: bad command startup -- throttling
I tried to follow this:
http://www.debuntu.org/postfix-and-p...filter-spam-p2
 
Old 10-05-2011, 03:55 AM   #6
Emil M
LQ Newbie
 
Registered: Feb 2010
Posts: 25

Original Poster
Rep: Reputation: 0
Solved!

I had this in my main.cf

Code:
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination,
    reject_invalid_hostname,
    reject_unauth_pipelining,
    reject_non_fqdn_sender,
    reject_unknown_sender_domain,
    reject_non_fqdn_recipient,
    reject_unknown_recipient_domain,
    check_client_access hash:$config_directory/access_client,
    check_sender_access hash:$config_directory/access_sender
    permit
worked when i removed the last 3 lines
 
Old 10-05-2011, 04:47 AM   #7
Emil M
LQ Newbie
 
Registered: Feb 2010
Posts: 25

Original Poster
Rep: Reputation: 0
It looks like it doesn't look up for the right account, and just uses spamd system user?

Code:
Oct  5 11:45:50.601 [21443] dbg: config: Conf::SQL: executing SQL: select preference, value from userpref where username = 'spamd' or username = '@GLOBAL' order by username asc

to start spamd i use
Code:
-q -x -u spamd -D

-- That's for sure the problem! It works when I use @GLOBAL or spamd as account, how do I combine these rules with virtual SQL users?



Maybe user should be ${recipient} in postfix? My conclusion: No!

Code:
postfix  21541 20259  0 11:58 ?        00:00:00 pipe -n spamassassin -t unix user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
root     21557     1  1 11:58 ?        00:00:01 /usr/sbin/spamd -d -m5 -x -q -Q -u nobody
nobody   21558 21557  0 11:58 ?        00:00:00 spamd child
nobody   21559 21557  0 11:58 ?        00:00:00 spamd child
root     21577 21268  0 12:00 pts/1    00:00:00 grep spamd

Last edited by Emil M; 10-05-2011 at 05:07 AM.
 
Old 10-05-2011, 05:19 AM   #8
Emil M
LQ Newbie
 
Registered: Feb 2010
Posts: 25

Original Poster
Rep: Reputation: 0
I've read that I should use a custom query for my purpose in /etc/spamassassin/local.cf, so I used this one as the documentation said, but without any luck:

Code:
user_scores_sql_custom_query     SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_ OR username = '@GLOBAL' ORDER BY username ASC
It works with @GLOBAL, but accounts doesn't.

Last edited by Emil M; 10-06-2011 at 08:10 AM.
 
Old 10-05-2011, 05:56 AM   #9
Emil M
LQ Newbie
 
Registered: Feb 2010
Posts: 25

Original Poster
Rep: Reputation: 0
Got it !

http://serversupportforum.de/forum/m...elle-user.html

In /etc/postfix/master.cf

argv=/usr/bin/spamc -u ${recipient}

It's important to have -u ${recipient}


Thanks for the links to get started, TB0ne. Hope someone some day can use my thoughts here.
 
Old 10-05-2011, 10:06 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by Emil M View Post
Got it !

http://serversupportforum.de/forum/m...elle-user.html

In /etc/postfix/master.cf

argv=/usr/bin/spamc -u ${recipient}

It's important to have -u ${recipient}
Thanks for the links to get started, TB0ne. Hope someone some day can use my thoughts here.
No problems..glad it helped. And thanks to your following up on what you've done and how, you've already helped quite a few folks with the same issue/question.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
postfix filter outgoing mail by sender domain dmfelix Linux - Server 2 06-18-2010 03:32 AM
Email content filter rules for either postfix or qmail even any good mail server wasamzy Linux - Server 7 02-06-2010 03:15 AM
Creating Mail Filter in Thunderbird mail client msivasakthi Linux - Software 1 07-14-2008 02:05 AM
postfix filter...help id_viorel Linux - Newbie 2 07-20-2004 08:22 AM
Spam filter to external mail filter deadlock Linux - Software 1 06-16-2004 02:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration