Because ASSP is proxying (and is not transparent) all the incoming traffic will seem to come from the server's own IP for Postfix.
This would turn your setup into an open relay.
To prevent this you should let ASSP only accept domains that are in files/localdomains.txt and files/localaddresses.txt
To automate the creation of those entries I created a script.
This script should be run as a 15-minute cronjob.
It manages the file /opt/ASSP/files/localdomains.txt by reading the MySQL database and /etc/postfix/relay_domains
It also manages the file files/localaddresses.txt
Each domain will get a *@<domain> automatically in that file.
You can optionally add an email-address for a specific domain and from that moment on it will only accept that address for that domain.
The address can be put anywhere in the file.
The script will take care of a neat format. Just check it out after it ran and you will see what I mean.
There's no need to do this for the Plesk domains
Because ASSP is directly proxying for Postix you should let Postfix decide if an address is to be accepted.
Postfix knows this for all the Plesk domains.
It's only useful for the domains for which postfix is relaying (/etc/postfix/relay_domains & /etc/postfix/transport).
Because it doesn't know immediately which addresses are accepted.
cat /usr/local/sbin/assp_localdomains
ln -s /usr/local/sbin/assp_localdomains /etc/cron.15min/
Code:
#!/bin/sh
LOCALDOMAINS=/opt/ASSP/files/localdomains.txt
LOCALADDRESSES=/opt/ASSP/files/localaddresses.txt
POSTFIXDIR=/etc/postfix
RELAYFILE=${POSTFIXDIR}/relay_domains
TRANSPORTFILE=${POSTFIXDIR}/transport
HEADER="# WARNING do not EDIT!!! \n# This file will be overwritten by $0 (`readlink -f $0`)"
FGROUP=`stat -c%G ${LOCALDOMAINS}`
FUSER=`stat -c%U ${LOCALDOMAINS}`
TMP1=`mktemp`
TMP2=`mktemp`
TMP3=`mktemp`
chown ${FUSER}.${FGROUP} ${TMP1}
chown ${FUSER}.${FGROUP} ${TMP2}
echo -e "${HEADER}\n" >${TMP1}
echo -e "################################################\n# Domains coming from Plesk\n################################################" >>${TMP1}
mysql --skip-column-names -uadmin -p`cat /etc/psa/.psa.shadow` psa -e "select domains.name from mail,domains,accounts where mail.dom_id=domains.id and mail.account_id=accounts.id;" 2>/dev/null >${TMP2}
mysql --skip-column-names -uadmin -p`cat /etc/psa/.psa.shadow` psa -e "select domain_aliases.name from domain_aliases where domain_aliases.mail='true';" 2>/dev/null >>${TMP2}
sort -u ${TMP2} >>${TMP1}
echo -e "\n################################################" >>${TMP1}
if [ -e "${RELAYFILE}" ] ; then
echo -e "# Domains coming from ${RELAYFILE}\n################################################" >>${TMP1}
awk '{print $1}' "${RELAYFILE}" >>${TMP1}
else
echo -e "\n# ${RELAYFILE} does NOT exist!!\n################################################" >>${TMP1}
fi
if ! diff ${TMP1} ${LOCALDOMAINS} >/dev/null 2>&1 ; then
cp -p ${TMP1} ${LOCALDOMAINS}
killall -HUP assp.pl
fi
# All addresses without wildcards
egrep -o '^.*@[a-z0-9.]+\.[a-z]+' ${LOCALADDRESSES} | grep -v '^\*@' | sort -u | sort -k2 -t@ >${TMP1}
# Only the domains of these addresses
awk -F@ '{print $2}' ${TMP1} | sort | uniq | sed 's/.*/^&$/g'>${TMP3}
# Start building LOCALADDRESSES
echo -e "################################################\n# Warning!\n# This file is maintained by $0 (`readlink -f $0`)\n# You can add an e-mail address for one of the local domains,\n# but this means all other addresses of that domain will get rejected.\n################################################\n\n\n################################################\n# Wildcards first (all addresses are accepted by ASSP)\n# The MTA can still reject the mail\n################################################\n" >${TMP2}
# Make wildcards for all domains except the ones that have already a full address defined
egrep '^[a-z][a-z0-9.-]+\.[a-z]+$' ${LOCALDOMAINS} | grep -vf ${TMP3} | sort -u | sed 's/.*/*@&/g' >>${TMP2}
echo -e "\n\n################################################\n# Only these addresses will be accepted by ASSP\n################################################\n" >>${TMP2}
sed -ie 's/\^/@/g;s/\$//g' ${TMP3}
while read DOMAIN ; do
echo -e "\n################################################" >>${TMP2}
echo "## ${DOMAIN}" >>${TMP2}
echo -e "################################################" >>${TMP2}
grep "[a-z0-9_]${DOMAIN}" ${TMP1} >>${TMP2}
done <${TMP3}
if ! diff ${TMP2} ${LOCALADDRESSES} >/dev/null 2>&1 ; then
cp -p ${TMP2} ${LOCALADDRESSES}
killall -HUP assp.pl
fi
rm -f ${TMP1}
rm -f ${TMP2}
rm -f ${TMP3}