[vhffs-dev] [2248] Fixed exim4 example config for PostgreSQL 9.x |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2248
Author: gradator
Date: 2014-07-16 11:31:20 +0200 (Wed, 16 Jul 2014)
Log Message:
-----------
Fixed exim4 example config for PostgreSQL 9.x
PostgreSQL from 8.x to 9.x changed the PostgreSQL default setting of
standard_conforming_strings from 'no' to 'yes', which means that the
database now treats backslash characters in a string as ordinary
characters. This in turn breaks the Exim implementation of
pgsql_quote(), which apparently adds a backslash in front of every
percent and underscore character, leading to corrupted SQL statements
being sent to the SQL server.
Modified Paths:
--------------
trunk/vhffs-doc/config/exim4-mx1/00_vhffs-main
trunk/vhffs-doc/config/exim4-mx1/exim4.conf
trunk/vhffs-doc/config/exim4-mx2/00_vhffs
trunk/vhffs-doc/config/exim4-mx2/exim4.conf
Modified: trunk/vhffs-doc/config/exim4-mx1/00_vhffs-main
===================================================================
--- trunk/vhffs-doc/config/exim4-mx1/00_vhffs-main 2014-07-06 20:24:50 UTC (rev 2247)
+++ trunk/vhffs-doc/config/exim4-mx1/00_vhffs-main 2014-07-16 09:31:20 UTC (rev 2248)
@@ -3,23 +3,23 @@
VHFFS_MAIL_HOME=/data/mail/boxes
# Domains handled by VHFFS (no matter if it is by forwarding, mailing listing or local delivering)
-VHFFS_LOCAL_DOMAINS = ${lookup pgsql{SELECT mx.domain FROM vhffs_mxdomain mx INNER JOIN vhffs_object o ON o.object_id=mx.object_id WHERE o.state = 6 AND domain = '${quote_pgsql:$domain}'}}
+VHFFS_LOCAL_DOMAINS = ${lookup pgsql{SELECT mx.domain FROM vhffs_mxdomain mx INNER JOIN vhffs_object o ON o.object_id=mx.object_id WHERE o.state = 6 AND domain = E'${quote_pgsql:$domain}'}}
# Used to determine if we perform local delivery for the mail we're processing
-VHFFS_VIRTUAL_LOCAL_DOMAINS = ${lookup pgsql{select vhffs_boxes.domain from vhffs_boxes where local_part = '${quote_pgsql:$local_part}' and vhffs_boxes.domain = '${quote_pgsql:$domain}' and vhffs_boxes.state = 6}}
+VHFFS_VIRTUAL_LOCAL_DOMAINS = ${lookup pgsql{select vhffs_boxes.domain from vhffs_boxes where local_part = E'${quote_pgsql:$local_part}' and vhffs_boxes.domain = E'${quote_pgsql:$domain}' and vhffs_boxes.state = 6}}
# Gets the Maildir path for a given address
-VHFFS_VIRTUAL_LOCAL_DIR = VHFFS_MAIL_HOME/${lookup pgsql{select d.boxes_path || '/' || b.mbox_name from vhffs_mxdomain d inner join vhffs_boxes b on b.domain = d.domain where d.domain = '${quote_pgsql:$domain}' and b.local_part = '${quote_pgsql:$local_part}'}{$value}fail}/Maildir
+VHFFS_VIRTUAL_LOCAL_DIR = VHFFS_MAIL_HOME/${lookup pgsql{select d.boxes_path || '/' || b.mbox_name from vhffs_mxdomain d inner join vhffs_boxes b on b.domain = d.domain where d.domain = E'${quote_pgsql:$domain}' and b.local_part = E'${quote_pgsql:$local_part}'}{$value}fail}/Maildir
# Get the remote address for a forward (isn't executed if we've got a local box (since we stop processing
# and vhffs doesn't allow multiple boxes/forwards/ml with the same localpart))
-VHFFS_FORWARD_ADDRESS = ${lookup pgsql{select remote_name from vhffs_forward where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
+VHFFS_FORWARD_ADDRESS = ${lookup pgsql{select remote_name from vhffs_forward where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}'}}
# Request returning a result if the current mail has a mailing list as recipient
-VHFFS_ML_EXISTS = ${lookup pgsql{select domain from vhffs_ml where local_part='${quote_pgsql:$local_part}' and domain='${quote_pgsql:$domain}'}}
+VHFFS_ML_EXISTS = ${lookup pgsql{select domain from vhffs_ml where local_part=E'${quote_pgsql:$local_part}' and domain=E'${quote_pgsql:$domain}'}}
# Returns the catchall address for a domain, if defined
-VHFFS_VIRTUAL_CATCHALL = ${lookup pgsql{select catchall from vhffs_mxdomain where domain = '${quote_pgsql:$domain}' and catchall != ''}}
+VHFFS_VIRTUAL_CATCHALL = ${lookup pgsql{select catchall from vhffs_mxdomain where domain = E'${quote_pgsql:$domain}' and catchall != ''}}
# Mailing lists configuration
Modified: trunk/vhffs-doc/config/exim4-mx1/exim4.conf
===================================================================
--- trunk/vhffs-doc/config/exim4-mx1/exim4.conf 2014-07-06 20:24:50 UTC (rev 2247)
+++ trunk/vhffs-doc/config/exim4-mx1/exim4.conf 2014-07-16 09:31:20 UTC (rev 2248)
@@ -1,26 +1,26 @@
#hide pgsql_servers = PGHOST/PGDB/PGUSER/PGPASS
hide pgsql_servers = 127.0.0.1/vhffs/vhffs/vhffs
-VHFFS_LOCAL_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_object omx ON omx.object_id=mx.object_id WHERE mx.domain='${quote_pgsql:$domain}' AND omx.state=6}}
+VHFFS_LOCAL_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_object omx ON omx.object_id=mx.object_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND omx.state=6}}
VHFFS_VIRTUAL_LOCAL_ROOT = /data/mail/boxes
-VHFFS_VIRTUAL_LOCAL_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}' AND box.state=6}}
-VHFFS_VIRTUAL_LOCAL_DIR = VHFFS_VIRTUAL_LOCAL_ROOT/${lookup pgsql{SELECT substr(mx.domain,1,1)||'/'||substr(mx.domain,2,1)||'/'||mx.domain||'/'||substr(lp.localpart,1,1)||'/'||lp.localpart FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}' AND box.state=6}{$value}fail}/Maildir
+VHFFS_VIRTUAL_LOCAL_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND lp.localpart=E'${quote_pgsql:$local_part}' AND box.state=6}}
+VHFFS_VIRTUAL_LOCAL_DIR = VHFFS_VIRTUAL_LOCAL_ROOT/${lookup pgsql{SELECT substr(mx.domain,1,1)||'/'||substr(mx.domain,2,1)||'/'||mx.domain||'/'||substr(lp.localpart,1,1)||'/'||lp.localpart FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND lp.localpart=E'${quote_pgsql:$local_part}' AND box.state=6}{$value}fail}/Maildir
# note: PostgreSQL >= 9.0 supports string_agg(redir.redirect,',') syntax
-VHFFS_VIRTUAL_REDIRECT_DATA = ${lookup pgsql{SELECT array_to_string(array_agg(redir.redirect),',') FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_redirect redir ON redir.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}'}}
-VHFFS_ML_EXIST = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_ml ml ON ml.localpart_id=lp.localpart_id INNER JOIN vhffs_object oml ON oml.object_id=ml.object_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}' AND oml.state=6}}
+VHFFS_VIRTUAL_REDIRECT_DATA = ${lookup pgsql{SELECT array_to_string(array_agg(redir.redirect),',') FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_redirect redir ON redir.localpart_id=lp.localpart_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND lp.localpart=E'${quote_pgsql:$local_part}'}}
+VHFFS_ML_EXIST = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_ml ml ON ml.localpart_id=lp.localpart_id INNER JOIN vhffs_object oml ON oml.object_id=ml.object_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND lp.localpart=E'${quote_pgsql:$local_part}' AND oml.state=6}}
# note: PostgreSQL >= 9.0 supports string_agg(lpbox.localpart||'^catchall^@'||mxbox.domain,',') syntax
-PGSQL_VIRTUAL_CATCHALL = ${lookup pgsql{SELECT array_to_string(array_agg(lpbox.localpart||'^catchall^@'||mxbox.domain),',') FROM vhffs_mx mx INNER JOIN vhffs_mx_catchall ca ON mx.mx_id=ca.mx_id INNER JOIN vhffs_mx_box box ON box.box_id=ca.box_id INNER JOIN vhffs_mx_localpart lpbox ON lpbox.localpart_id=box.localpart_id INNER JOIN vhffs_mx mxbox ON mxbox.mx_id=lpbox.mx_id WHERE mx.domain='${quote_pgsql:$domain}' AND box.state=6}}
-#PGSQL_GET_TX_USER = ${lookup pgsql{select vhffs_user_info.mail from vhffs_user_info, vhffs_users where vhffs_users.uid=vhffs_user_info.uid and vhffs_users.username='${quote_pgsql:$local_part}' and 'vhffs.org'='${quote_pgsql:$domain}'}}
-#PGSQL_VIRTUAL_LOCAL_QUOTA = ${lookup pgsql{select quota from popbox where local_part = '${quote_pgsql:$local_part}' and domaine = '${quote_pgsql:$domain}'}}
-#PGSQL_VIRTUAL_LOCAL_QFILE = ${lookup pgsql{select quota_f from popbox where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
-#PGSQL_VIRTUAL_LOCAL_Q_WARN = ${lookup pgsql{select quota_warn from popbox where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
-#PGSQL_VIRTUAL_LOCAL_UP_QUOTA = ${lookup pgsql{update popbox set quota_f_used = '${quote_pgsql:$quota_total_fcount}', quota_used = '${quote_pgsql:$quota_total_used}' where local_part = '${quote_pgsql:$local_part}' and domain_name = '${quote_pgsql:$domain}'}}
-#PGSQL_VIRTUAL_SPAMCHECK = ${lookup pgsql{select domain_name from mxdomain where mxdomain.domain_name = '${quote_pgsql:$domain}' and scan = 1}}
-##VHFFS_AUTOREPLY_DOMAINS = ${lookup pgsql{select domain from vhffs_autoreply where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}' and current_date between period_start and period_end}}
-##VHFFS_AUTOREPLY_TEXT = ${lookup pgsql{select message from vhffs_autoreply where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
-##VHFFS_AUTOREPLY_SUBJECT = ${lookup pgsql{select subject from vhffs_autoreply where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
+PGSQL_VIRTUAL_CATCHALL = ${lookup pgsql{SELECT array_to_string(array_agg(lpbox.localpart||'^catchall^@'||mxbox.domain),',') FROM vhffs_mx mx INNER JOIN vhffs_mx_catchall ca ON mx.mx_id=ca.mx_id INNER JOIN vhffs_mx_box box ON box.box_id=ca.box_id INNER JOIN vhffs_mx_localpart lpbox ON lpbox.localpart_id=box.localpart_id INNER JOIN vhffs_mx mxbox ON mxbox.mx_id=lpbox.mx_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND box.state=6}}
+#PGSQL_GET_TX_USER = ${lookup pgsql{select vhffs_user_info.mail from vhffs_user_info, vhffs_users where vhffs_users.uid=vhffs_user_info.uid and vhffs_users.username=E'${quote_pgsql:$local_part}' and 'vhffs.org'=E'${quote_pgsql:$domain}'}}
+#PGSQL_VIRTUAL_LOCAL_QUOTA = ${lookup pgsql{select quota from popbox where local_part = E'${quote_pgsql:$local_part}' and domaine = E'${quote_pgsql:$domain}'}}
+#PGSQL_VIRTUAL_LOCAL_QFILE = ${lookup pgsql{select quota_f from popbox where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}'}}
+#PGSQL_VIRTUAL_LOCAL_Q_WARN = ${lookup pgsql{select quota_warn from popbox where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}'}}
+#PGSQL_VIRTUAL_LOCAL_UP_QUOTA = ${lookup pgsql{update popbox set quota_f_used = E'${quote_pgsql:$quota_total_fcount}', quota_used = E'${quote_pgsql:$quota_total_used}' where local_part = E'${quote_pgsql:$local_part}' and domain_name = E'${quote_pgsql:$domain}'}}
+#PGSQL_VIRTUAL_SPAMCHECK = ${lookup pgsql{select domain_name from mxdomain where mxdomain.domain_name = E'${quote_pgsql:$domain}' and scan = 1}}
+##VHFFS_AUTOREPLY_DOMAINS = ${lookup pgsql{select domain from vhffs_autoreply where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}' and current_date between period_start and period_end}}
+##VHFFS_AUTOREPLY_TEXT = ${lookup pgsql{select message from vhffs_autoreply where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}'}}
+##VHFFS_AUTOREPLY_SUBJECT = ${lookup pgsql{select subject from vhffs_autoreply where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}'}}
##VHFFS_AUTOREPLY_ONCE_HOME = /data/mail/onces
-##VHFFS_AUTOREPLY_ONCE_DIR = VHFFS_AUTOREPLY_ONCE_HOME/${lookup pgsql{SELECT boxes_path FROM vhffs_mxdomain WHERE domain = '${quote_pgsql:$domain}'}}
-##VHFFS_SPAM_STATUS = ${lookup pgsql{select nospam from vhffs_boxes where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}' union select nospam from vhffs_ml where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
+##VHFFS_AUTOREPLY_ONCE_DIR = VHFFS_AUTOREPLY_ONCE_HOME/${lookup pgsql{SELECT boxes_path FROM vhffs_mxdomain WHERE domain = E'${quote_pgsql:$domain}'}}
+##VHFFS_SPAM_STATUS = ${lookup pgsql{select nospam from vhffs_boxes where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}' union select nospam from vhffs_ml where local_part = E'${quote_pgsql:$local_part}' and domain = E'${quote_pgsql:$domain}'}}
LISTENGINE_HOME=/usr/lib/vhffs/listengine/
LISTENGINE_QUEUE=LISTENGINE_HOME/listengine.pl
@@ -498,7 +498,7 @@
plain:
driver = plaintext
public_name = PLAIN
- server_condition = ${if and{ {!eq{$auth2}{}}{!eq{$auth3}{}}{crypteq {$auth3} {\{crypt\}${lookup pgsql{SELECT lp.password FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain='${quote_pgsql:${domain:$auth2}}' AND lp.localpart='${quote_pgsql:${local_part:$auth2}}'} {$value}fail}}}}{1}{0}}
+ server_condition = ${if and{ {!eq{$auth2}{}}{!eq{$auth3}{}}{crypteq {$auth3} {\{crypt\}${lookup pgsql{SELECT lp.password FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain=E'${quote_pgsql:${domain:$auth2}}' AND lp.localpart=E'${quote_pgsql:${local_part:$auth2}}'} {$value}fail}}}}{1}{0}}
server_set_id = $auth2
server_prompts = :
# server_advertise_condition = ${if def:tls_cipher }
@@ -507,7 +507,7 @@
driver = plaintext
public_name = LOGIN
server_prompts = Username:: : Password::
- server_condition = ${if and{ {!eq{$auth1}{}}{!eq{$auth2}{}}{crypteq {$auth2} {\{crypt\}${lookup pgsql{SELECT lp.password FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain='${quote_pgsql:${domain:$auth1}}' AND lp.localpart='${quote_pgsql:${local_part:$auth1}}'} {$value}fail}}}}{1}{0}}
+ server_condition = ${if and{ {!eq{$auth1}{}}{!eq{$auth2}{}}{crypteq {$auth2} {\{crypt\}${lookup pgsql{SELECT lp.password FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain=E'${quote_pgsql:${domain:$auth1}}' AND lp.localpart=E'${quote_pgsql:${local_part:$auth1}}'} {$value}fail}}}}{1}{0}}
server_set_id = $auth1
# server_advertise_condition = ${if def:tls_cipher }
Modified: trunk/vhffs-doc/config/exim4-mx2/00_vhffs
===================================================================
--- trunk/vhffs-doc/config/exim4-mx2/00_vhffs 2014-07-06 20:24:50 UTC (rev 2247)
+++ trunk/vhffs-doc/config/exim4-mx2/00_vhffs 2014-07-16 09:31:20 UTC (rev 2248)
@@ -1,10 +1,10 @@
hide pgsql_servers = 127.0.0.1/vhffs/exim/astrongpass
# Domains to be relayed
-VHFFS_RELAY_DOMAINS = ${lookup pgsql{SELECT mx.domain FROM vhffs_mxdomain mx INNER JOIN vhffs_object o ON o.object_id=mx.object_id WHERE o.state = 6 AND domain = '${quote_pgsql:$domain}'}}
+VHFFS_RELAY_DOMAINS = ${lookup pgsql{SELECT mx.domain FROM vhffs_mxdomain mx INNER JOIN vhffs_object o ON o.object_id=mx.object_id WHERE o.state = 6 AND domain = E'${quote_pgsql:$domain}'}}
# Checks localparts (to avoid forwarding mail to non-existent boxes).
-VHFFS_VALID_LOCALPARTS = ${lookup pgsql{SELECT d.domain FROM vhffs_mxdomain d WHERE d.domain = '${quote_pgsql:$domain}' AND (d.catchall != '' OR EXISTS (SELECT domain FROM vhffs_boxes WHERE domain = '${quote_pgsql:$domain}' AND local_part = '${quote_pgsql:$local_part}' AND state = 6) OR EXISTS (SELECT domain FROM vhffs_forward WHERE domain = '${quote_pgsql:$domain}' AND local_part = '${quote_pgsql:$local_part}') OR EXISTS (SELECT domain FROM vhffs_ml WHERE domain = '${quote_pgsql:$domain}' AND (local_part = '${quote_pgsql:$local_part}' OR local_part || '-request' = '${quote_pgsql:$local_part}')))}}
+VHFFS_VALID_LOCALPARTS = ${lookup pgsql{SELECT d.domain FROM vhffs_mxdomain d WHERE d.domain = E'${quote_pgsql:$domain}' AND (d.catchall != '' OR EXISTS (SELECT domain FROM vhffs_boxes WHERE domain = E'${quote_pgsql:$domain}' AND local_part = E'${quote_pgsql:$local_part}' AND state = 6) OR EXISTS (SELECT domain FROM vhffs_forward WHERE domain = E'${quote_pgsql:$domain}' AND local_part = E'${quote_pgsql:$local_part}') OR EXISTS (SELECT domain FROM vhffs_ml WHERE domain = E'${quote_pgsql:$domain}' AND (local_part = E'${quote_pgsql:$local_part}' OR local_part || '-request' = E'${quote_pgsql:$local_part}')))}}
# Self explanatory. We only accept to relay on this address.
MX1_IP_ADDRESS=123.45.67.89
Modified: trunk/vhffs-doc/config/exim4-mx2/exim4.conf
===================================================================
--- trunk/vhffs-doc/config/exim4-mx2/exim4.conf 2014-07-06 20:24:50 UTC (rev 2247)
+++ trunk/vhffs-doc/config/exim4-mx2/exim4.conf 2014-07-16 09:31:20 UTC (rev 2248)
@@ -1,11 +1,11 @@
#hide pgsql_servers = PGHOST/PGDB/PGUSER/PGPASS
hide pgsql_servers = 127.0.0.1/vhffs/vhffs/vhffs
# Use these query if your MX2 directly uses VHFFS database
-#PGSQL_RELAY_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_object omx ON omx.object_id=mx.object_id WHERE mx.domain='${quote_pgsql:$domain}' AND omx.state=6}}
-#PGSQL_RELAY_CHECKLOCALPART = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx WHERE mx.domain='${quote_pgsql:$domain}' AND ( EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_catchall ca ON mx.mx_id=ca.mx_id INNER JOIN vhffs_mx_box box ON box.box_id=ca.box_id INNER JOIN vhffs_mx_localpart lpbox ON lpbox.localpart_id=box.localpart_id INNER JOIN vhffs_mx mxbox ON mxbox.mx_id=lpbox.mx_id WHERE mx.domain='${quote_pgsql:$domain}' AND box.state=6) OR EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}' AND box.state=6) OR EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_redirect redir ON redir.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}') OR EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_ml ml ON ml.localpart_id=lp.localpart_id INNER JOIN vhffs_object oml ON oml.object_id=ml.object_id WHERE mx.domain='${quote_pgsql:$domain}' AND (lp.localpart='${quote_pgsql:$local_part}' OR lp.localpart||'-request' = '${quote_pgsql:$local_part}') AND oml.state=6))}}
+#PGSQL_RELAY_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_object omx ON omx.object_id=mx.object_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND omx.state=6}}
+#PGSQL_RELAY_CHECKLOCALPART = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx WHERE mx.domain=E'${quote_pgsql:$domain}' AND ( EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_catchall ca ON mx.mx_id=ca.mx_id INNER JOIN vhffs_mx_box box ON box.box_id=ca.box_id INNER JOIN vhffs_mx_localpart lpbox ON lpbox.localpart_id=box.localpart_id INNER JOIN vhffs_mx mxbox ON mxbox.mx_id=lpbox.mx_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND box.state=6) OR EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND lp.localpart=E'${quote_pgsql:$local_part}' AND box.state=6) OR EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_redirect redir ON redir.localpart_id=lp.localpart_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND lp.localpart=E'${quote_pgsql:$local_part}') OR EXISTS (SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_ml ml ON ml.localpart_id=lp.localpart_id INNER JOIN vhffs_object oml ON oml.object_id=ml.object_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND (lp.localpart=E'${quote_pgsql:$local_part}' OR lp.localpart||'-request' = E'${quote_pgsql:$local_part}') AND oml.state=6))}}
# Use these query if your MX has a mirrored VHFFS db (using mirror-mx2.pl)
-PGSQL_RELAY_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx2 mx WHERE mx.domain='${quote_pgsql:$domain}'}}
-PGSQL_RELAY_CHECKLOCALPART = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx2 mx WHERE mx.domain='${quote_pgsql:$domain}' AND (mx.catchall=true OR EXISTS (SELECT mx.domain FROM vhffs_mx2 mx INNER JOIN vhffs_mx2_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}'))}}
+PGSQL_RELAY_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx2 mx WHERE mx.domain=E'${quote_pgsql:$domain}'}}
+PGSQL_RELAY_CHECKLOCALPART = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx2 mx WHERE mx.domain=E'${quote_pgsql:$domain}' AND (mx.catchall=true OR EXISTS (SELECT mx.domain FROM vhffs_mx2 mx INNER JOIN vhffs_mx2_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain=E'${quote_pgsql:$domain}' AND lp.localpart=E'${quote_pgsql:$local_part}'))}}
exim_path = /usr/sbin/exim4