On 11/17/20 12:57 PM, Viktor Dukhovni wrote:
On Tue, Nov 17, 2020 at 12:43:23PM -0800, David Koski wrote:

In effort to relay by default, except for specific domains, I have
configured a mysql transport table as follows:

+--------------------+-------------------------------+
| tkey               | transport                     |
+--------------------+-------------------------------+
| *                  | 
relay:[https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fbarracuda.mydomai.com&c=E,1,0l2E8scUBXRsSEOkKZaB7SO-NteYRXb7ws1Tgqg4Du9zM1NuUNWpr07b2O_Lo7YbknkjTrufaG1BQbdUCXZiYlPCg2fabHwzZ3l-ONug&typo=1]
 |
| .hotmail.com       | smtp:hotmail.com              |
| @hotmail.com       | smtp:hotmail.com              |
| hotmail.com        | smtp:hotmail.com              |
+--------------------+-------------------------------+
Since the issue is with transport lookups...  While posting
"postconf -n" output is appreciated, only its transport_maps
setting is relevant in this case:

transport_maps = 
proxy:mysql:/etc/postfix/https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fmysql_transport_maps.cf&c=E,1,Xss3AF26YcN3GWWupQPrc3p9sUy-IXwZLo2EXOg4IN7igFQiH1CDFQo1mGXYzq-jZEY5k4YoGKvW3yIhxUDoRLIGPIpRTgADUq_vtL0MFoZd51_Jd4U5AaAa7Osv&typo=1
But you've not posted (after eliding any password settings and if you
like also the server hostname) the content of the table definition,
i.e. /etc/postfix/mysql_transport_maps.cf.

Here you probably have a "domain" or similar setting that limits the
keys actually used for lookups.

You can check with:

     postmap -q "*" 
mysql:/etc/postfix/https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fmysql_transport_maps.cf&c=E,1,E-5fbnQWo41fSScPm6oDDInTKnmzQGgV7n-4Rg3OewGnO9sgcZrZAk7vS6j1Eer19iLWWhIqZc47GZmVJuZukbAMyI7NTaA_J_R4K_shDfKIEnI,&typo=1

# postmap -q "*" mysql:/etc/postfix/mysql_transport_maps.cf
(does not return a text value)

Additional information:

+--------------------+-------------------------------+
| tkey               | transport                     |
+--------------------+-------------------------------+
| *                  | relay:[barracuda.mydomai.com] |
| .hotmail.com       | error:                        |
| @hotmail.com       | error:                        |
| hotmail.com        | error:                        |
| [email protected]  | error:                        |
+--------------------+-------------------------------+


# postmap -q [email protected] mysql:/etc/postfix/mysql_transport_maps.cf
error:

# postmap -q hotmail.com mysql:/etc/postfix/mysql_transport_maps.cf
(does not return a text value)

Contents of mysql_transport_maps.cf:

  1 user = vmail
  2 password = secret
  3 hosts = 127.0.0.1
  4 dbname = vmail
  5
  6
  7
  8 query =
  9     SELECT transport FROM (
 10         SELECT
 11             /* Transport table is highest rank */
 12             1 as rank,
 13             REPLACE( transport, 'smtp:[68.66.148.91]', 'dovecot:') AS transport
 14         FROM
 15             view_transport
 16         WHERE
 17             tkey='%s'
 18     UNION ALL
 19         SELECT
 20             /* If not in transport table, check psudo transport table */
 21             2 as rank,
 22             REPLACE( transport, 'smtp:[68.66.148.91]', 'dovecot:') AS transport
 23         FROM
 24             view_user_transport
 25         WHERE
 26             tkey='%s' AND relay_domain<'2'
 27     UNION ALL
 28         SELECT
 29             /* If nothing else, check if relay domain */
 30             3 as rank,
 31             'relay:' AS transport
 32         FROM
 33             virtual_domains
 34         WHERE
 35             name='%d' AND relay<>'0'
 36         ) t ORDER BY rank
 37     LIMIT 1
 38

This I got from the mysql log when sending to [email protected], then formatted it for multi line to read the substitutions:

  1 SELECT transport FROM (
  2     SELECT
  3         /* Transport table is highest rank */
  4         1 as rank,
  5         REPLACE( transport, 'smtp:[68.66.148.91]', 'dovecot:') AS transport
  6     FROM
  7         view_transport
  8     WHERE
  9         tkey='[email protected]'
 10 UNION ALL
 11     SELECT
 12         /* If not in transport table, check psudo transport table */
 13         2 as rank,
 14         REPLACE( transport, 'smtp:[68.66.148.91]', 'dovecot:') AS transport
 15     FROM
 16         view_user_transport
 17     WHERE
 18         tkey='[email protected]' AND relay_domain<'2'
 19 UNION ALL
 20     SELECT
 21         /* If nothing else, check if relay domain */
 22         3 as rank,
 23         'relay:' AS transport
 24     FROM
 25         virtual_domains
 26     WHERE
 27         name='hotmail.com' AND relay<>'0'
 28     ) t ORDER BY rank
 29 LIMIT 1
 30
:
It appears the transport maps only work for specific email addresses, not for domains or the wild card "*".  The query is executed only with the entire email address.  Note the substitution is working.  The complexity is due to support for split domains with a central database.  The same config works on multiple hosts with only the IP address changed for the individual hosts so that local delivery to dovecot works.

Regards,
David Koski
[email protected]


to see which keys are returning answers.  With "-v" you'll
see which queries are being sent (or not).


Reply via email to