d***@gmail.com
2014-04-23 15:28:48 UTC
We have a mail server requirement to relay mail from the Microsoft Office 365 mail to backend hosts depending on the receiving domain. Our application requirements are to have a database that can be populated with a list of domains and corresponding backend hostname:port information.
I have configured postfix with relay_domain.cf and relay_transport.cf configs and have a test postgres database with Domain Host columns. Here are my current configs:
main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = 365mail.ourdomain.net
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = <test range>
relay_domains = pgsql:/etc/postfix/pgsql/relay_domains.cf
relay_transport = pgsql:/etc/postfix/pgsql/relay_transport.cf
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 9
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
# relay_domains.cf
user = postfix
password = <password>
dbname = postfix
#hosts = localhost
query = SELECT domainname FROM portoffice365s WHERE domainname='%s'
# relay_domains.cf
user = postfix
password = <password>
dbname = postfix
#hosts = localhost
query = SELECT host FROM portoffice365s WHERE domainname='%s'
Running telnet tests sending mail to a test domain I see this in the logs:
Apr 22 16:24:23 365mail postfix/qmgr[12760]: 7C8311C07AE: from=<***@edgewave.com>, size=190, nrcpt=1 (queue active)
Apr 22 16:24:23 365mail postfix/qmgr[12760]: warning: connect to transport private/pgsql: No such file or directory
Apr 22 16:24:23 365mail postfix/error[12768]: 7C8311C07AE: to=<***@abc.com>, relay=none, delay=10, delays=10/0.01/0/0.01, dsn=4.3.0, status=deferred (mail transport unavailable)
Running command line tests yield:
postmap -q abc.com pgsql:/etc/postfix/pgsql/relay_domains.cf
abc.com
postmap -q abc.com pgsql:/etc/postfix/pgsql/relay_transport.cf
smtp:[port_outbound.2.31363.svt3.redcondor.net]:31363
Information pulled from the database seemingly correctly.
Hard coding the transport_relay in the main.cf works correctly but pulling from the database doesn't. Was hoping there was something obvious I'm missing here or just misunderstanding the process to complete the objective.
Any help would be appreciated.
I have configured postfix with relay_domain.cf and relay_transport.cf configs and have a test postgres database with Domain Host columns. Here are my current configs:
main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = 365mail.ourdomain.net
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = <test range>
relay_domains = pgsql:/etc/postfix/pgsql/relay_domains.cf
relay_transport = pgsql:/etc/postfix/pgsql/relay_transport.cf
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 9
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
# relay_domains.cf
user = postfix
password = <password>
dbname = postfix
#hosts = localhost
query = SELECT domainname FROM portoffice365s WHERE domainname='%s'
# relay_domains.cf
user = postfix
password = <password>
dbname = postfix
#hosts = localhost
query = SELECT host FROM portoffice365s WHERE domainname='%s'
Running telnet tests sending mail to a test domain I see this in the logs:
Apr 22 16:24:23 365mail postfix/qmgr[12760]: 7C8311C07AE: from=<***@edgewave.com>, size=190, nrcpt=1 (queue active)
Apr 22 16:24:23 365mail postfix/qmgr[12760]: warning: connect to transport private/pgsql: No such file or directory
Apr 22 16:24:23 365mail postfix/error[12768]: 7C8311C07AE: to=<***@abc.com>, relay=none, delay=10, delays=10/0.01/0/0.01, dsn=4.3.0, status=deferred (mail transport unavailable)
Running command line tests yield:
postmap -q abc.com pgsql:/etc/postfix/pgsql/relay_domains.cf
abc.com
postmap -q abc.com pgsql:/etc/postfix/pgsql/relay_transport.cf
smtp:[port_outbound.2.31363.svt3.redcondor.net]:31363
Information pulled from the database seemingly correctly.
Hard coding the transport_relay in the main.cf works correctly but pulling from the database doesn't. Was hoping there was something obvious I'm missing here or just misunderstanding the process to complete the objective.
Any help would be appreciated.