Hello,
I have been setting up a new server (mail.domain.com) to redirect mail to server1.domain.com and server2.domain.com depending on the domain the mail is sent to. I.e.
MX Record to mail.domain.com
Mail sent to hello.com -----------------------------> mail.domain.com uses Transport DB to redirect hello.com to server2.domain.com where another SMTP Server exists.
postconf -n
Code:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = /etc/postfix/local-host-names
myhostname = mail.domain.com
mynetworks = <<-Outside Domain->>, 127.0.0.0
myorigin = $mydomain
recipient_delimiter = +
relayhost = hello.com
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 450
master.cf
Code:
smtp inet n - n - - smtpd -o content_filter=spamassassin
......
spamassassin
unix - n n - - pipe
flags=Rq user=nobody argv=/var/spamassassin/filter.sh -oi -f ${sender} ${recipient}
filter.sh
Code:
#!/bin/sh
# filter.sh
#
# This script redirects mail flagged as spam to a separate account
# You must first create a user account named "spamvac" to hold the flagged mail
SENDMAIL="/usr/sbin/sendmail -i"
SPAMASSASSIN=/usr/bin/spamc
COMMAND="$SENDMAIL $@"
#If your SQL preferences set to "user"
USER=`echo $COMMAND | awk '{ print $NF }' | sed 's/@.*$//'`
#If your SQL preferences set to "user@domain"
#USER=`echo $COMMAND | awk '{ print $NF }'`
NEW_COMMAND=`echo $COMMAND | awk '{ $6 = "spamvac"; NF = 6; print }'`
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
umask 077
OUTPUT="`mktemp /tmp/mailfilter.XXXXXXXXXX`"
if [ "$?" != 0 ]; then
/usr/bin/logger -s -p mail.warning -t filter "Unable to create temporary file."
exit $EX_TEMPFAIL
fi
# Clean up when done or when aborting.
trap "rm -f $OUTPUT" EXIT TERM
$SPAMASSASSIN -x -E -u $USER > $OUTPUT
return="$?"
if [ "$return" = 1 ]; then
$NEW_COMMAND < $OUTPUT
exit $?
elif [ "$return" != 0 ]; then
/usr/bin/logger -s -p mail.warning -t filter "Temporary SpamAssassin failure (spamc returned $return)"
exit $EX_TEMPFAIL
fi
$SENDMAIL "$@" < $OUTPUT
exit $?
Error on Logfile when mail sent to
user@hello.com
Code:
May 20 12:21:47 s15348938 postfix/smtpd[15898]: connect from queueout01-winn.ispmail.ntl.com[81.103.221.31]
May 20 12:21:47 s15348938 postfix/smtpd[15898]: NOQUEUE: reject: RCPT from queueout01-winn.ispmail.ntl.com[81.103.221.31]: 450 4.1.1 <user@hello.com>: Recipient address rejected: User unknown in loca$
May 20 12:21:47 s15348938 postfix/smtpd[15898]: disconnect from queueout01-winn.ispmail.ntl.com[81.103.221.31]
transport db
Code:
hello.com smtp:server2.domain.com
Sorry there is a lot of code etc there.
Basically:
hello.com is the domain that should redirect
server1 & server2.domain.com are the servers that the mail should be redirected to
mail.domain.com is the redirecting server which I am having problems with (with SpamAssassin filter)
I seem to think that the mail arrives at mail.domain.com, and Postfix can't work out where to route the mail to.
Regards,
Matt