dbpath = /etc/postfix/private/mail.sqlite query = SELECT coalesce(T1.tpTransport, '') || ':' || (CASE WHEN tpMx=0 THEN '[' || coalesce(T1.tpNexthop, '') || ']' ELSE coalesce(T1.tpNexthop, '') END) || (CASE WHEN tpPort IS NOT NULL THEN ':' || tpPort ELSE '' END) FROM Transport AS T1 WHERE T1.active!=0 AND T1.tpNum= coalesce((SELECT coalesce(A2.addTpNum, D2.domTpNum) FROM Address AS A2 JOIN Domain AS D2 ON A2.addDomNum=D2.domNum WHERE A2.addLocalpart || '@' || D2.domName IS '%s' AND A2.active!=0), (SELECT D1.domTpNum FROM Domain AS D1 WHERE D1.domName IS '%s' AND D1.active!=0)) # Postfix transport(5) lookups # Case 1: queries for user-exten@domain # Case 2: queries for user@domain # Case 3: queries for domain (%u is suppressed) # Case 4: queries for .domain (%u is suppressed) # Case 5: queries for wildcard "*" (%u is suppressed) # This query will match any listed address without ever going to # Case 3. If there is an extension, it won't match unless # user-exten@domain is in the Addresses table. # # Matched domains without any address listings will be matched in # case 3 or 4. We don't have a wildcard in the sample data, but # there's no reason why it wouldn't work too. # # Unmatched domains will be searched through all cases.