LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-20-2014, 06:26 AM   #1
tiv
LQ Newbie
 
Registered: Oct 2014
Posts: 1

Rep: Reputation: Disabled
Question Postfix - redirect unknown users to SPAM mailbox


Hi there!

I have Postfix + BitDefender FRAMS running as hygiene gateway before few Exchanges.
BD FRAMS can learn it's Baesian filter by download SPAM and HAM emails from dedicated mailboxes.
Because we have sustain flow of SPAM to unknown recipients, I have idea to redirect this useful source of SPAM emails directly to SPAM-learning mailbox.

My configs:

main.cf:
Code:
myhostname = postfix.domain1.com
mynetworks = 127.0.0.0/8 xxx.xxx.xxx.xxx

relay_domains = hash:/etc/postfix/relay-domains
transport_maps = hash:/etc/postfix/transport
relay_recipient_maps = hash:/etc/postfix/relay-users
show_user_unknown_table_name = no
smtpd_delay_reject = yes
smtpd_banner = $myhostname
unknown_local_recipient_reject_code = 550

# Added by BitDefender on Fri Oct 17 13:20:04 UTC 2014
smtpd_milters=unix:/var/spool/postfix/BitDefender/bdmilterd.sock
milter_protocol = 2
milter_default_action = tempfail
milter_connect_timeout = 30s
milter_command_timeout = 30s
milter_content_timeout = 30s
# End of added lines
relay-domains:
Code:
#MyOrg1 Exchange
domain1.com OK

#MyOrg2 Exchange
domain2.com OK
relay-users:
Code:
user1@domain1.com OK
user2@domain1.com OK
user1@domain2.com OK
user2@domain2.com OK
transport:
Code:
#MyOrg1 Exchange
domain1.com smtp:exchange.domain1.com

#MyOrg2 Exchange
domain2.com smtp:exchange.domain2.com
my script for fill relay-users from AD (kindly share for you) for cron:
Code:
#!/bin/bash

#Global
LDAP_QUERY='(&(proxyAddresses=smtp:*)(!(objectClass=contact)))'

#Exchange Server 1
EX_SRV='exchange.domain1.com'
LDAP_SRV='ldap.domain1.com'
LDAP_SRV_USER='DOMAIN1\user'
LDAP_SRV_PASSWORD='password'
LDAP_SRV_BASEDN='DC=domain1,DC=com'
ldapsearch -xLLL -H ldap://$LDAP_SRV -s sub -D $LDAP_SRV_USER -w $LDAP_SRV_PASSWORD -b $LDAP_SRV_BASEDN $LDAP_QUERY | perl -p00e 's/\r?\n //g' | grep -i smtp: | cut -d: -f3- | sort | uniq > /etc/postfix/ldap-query-result-temp
cat /etc/postfix/ldap-query-result-temp | cut -d@ -f2- | sort | uniq | sed "s/$/ smtp:$EX_SRV/" > /etc/postfix/transport-temp
cat /etc/postfix/ldap-query-result-temp | cut -d@ -f2- | sort | uniq | sed 's/$/ OK/' > /etc/postfix/relay-domains-temp
cat /etc/postfix/ldap-query-result-temp | sort | uniq | sed 's/$/ OK/' > /etc/postfix/relay-users-temp
#Exchange Server 1

#Exchange Server 2
EX_SRV='exchange.domain2.com'
LDAP_SRV='ldap.domain2.com'
LDAP_SRV_USER='DOMAIN2\user'
LDAP_SRV_PASSWORD='password'
LDAP_SRV_BASEDN='DC=domain2,DC=com'
ldapsearch -xLLL -H ldap://$LDAP_SRV -s sub -D $LDAP_SRV_USER -w $LDAP_SRV_PASSWORD -b $LDAP_SRV_BASEDN $LDAP_QUERY | perl -p00e 's/\r?\n //g' | grep -i smtp: | cut -d: -f3- | sort | uniq > /etc/postfix/ldap-query-result-temp
cat /etc/postfix/ldap-query-result-temp | cut -d@ -f2- | sort | uniq | sed "s/$/ smtp:$EX_SRV/" >> /etc/postfix/transport-temp
cat /etc/postfix/ldap-query-result-temp | cut -d@ -f2- | sort| uniq | sed 's/$/ OK/' >> /etc/postfix/relay-domains-temp
cat /etc/postfix/ldap-query-result-temp | sort | uniq | sed 's/$/ OK/' >> /etc/postfix/relay-users-temp
#Exchange Server 2

#Exchange Server 3
#EX_SRV=''
#LDAP_SRV=''
#LDAP_SRV_USER=''
#LDAP_SRV_PASSWORD=''
#LDAP_SRV_BASEDN=''
#ldapsearch -xLLL -H ldap://$LDAP_SRV -s sub -D $LDAP_SRV_USER -w $LDAP_SRV_PASSWORD -b $LDAP_SRV_BASEDN $LDAP_QUERY | perl -p00e 's/\r?\n //g' | grep -i smtp: | cut -d: -f3- | sort | uniq > /etc/postfix/ldap-query-result-temp
#cat /etc/postfix/ldap-query-result-temp | cut -d@ -f2- | sort | uniq | sed "s/$/ smtp:$EX_SRV/" >> /etc/postfix/transport-temp
#cat /etc/postfix/ldap-query-result-temp | cut -d@ -f2- | sort| uniq | sed 's/$/ OK/' >> /etc/postfix/relay-domains-temp
#cat /etc/postfix/ldap-query-result-temp | uniq | sed 's/$/ OK/' >> /etc/postfix/relay-users-temp
#Exchange Server 3

mv -f /etc/postfix/relay-domains-temp /etc/postfix/relay-domains
mv -f /etc/postfix/relay-users-temp /etc/postfix/relay-users
mv -f /etc/postfix/transport-temp /etc/postfix/transport

rm -f /etc/postfix/ldap-query-result-temp

rm -f /etc/postfix/relay-domains.db
rm -f /etc/postfix/relay-users.db
rm -f /etc/postfix/transport.db

postmap hash://etc/postfix/relay-domains
postmap hash://etc/postfix/relay-users
postmap hash://etc/postfix/transport

postfix reload
If somebody know, how to do this, I will appreciated.
Thanks.

Last edited by tiv; 10-21-2014 at 06:45 AM. Reason: few mistakes
 
Old 10-23-2014, 05:27 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
luser_relay defines the disposition of unknown recipients.
http://www.postfix.org/postconf.5.html#luser_relay
 
  


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
Move SA Marked Spam to Junk/Spam Folder Using Procmail, Postfix, and Virtual Users alden_pease Linux - Server 0 01-05-2012 12:29 AM
Spam, Postfix, and Unknown Users zok Linux - Server 4 10-12-2007 02:56 PM
how can postfix redirect unknown users mail to postmaster LinuxLover Linux - Software 1 05-16-2006 08:54 AM
Help: Qmail unknown users spam ~=gr3p=~ Linux - Software 2 03-13-2006 06:44 AM
Postfix/Unknown Users ]SK[ Linux - Software 1 07-05-2005 05:24 PM

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

All times are GMT -5. The time now is 05:54 AM.

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