Redundant email servers with soft-fail (450) vs. hard-fail (550)

postfix_soft_fail

I manage a fairly large number of incoming mail exchangers, which are numerous both to handle large message volumes as well as to provide redundancy. In most cases, these mail servers are Postfix with MySQL providing virtual alias maps, transport maps, relay domains, and virtual alias domains. Unfortunately the Postfix+MySQL implementation isn’t always 100% great. On very rare occasions the Postfix instance may fail to communicate with the MySQL server, for any number of reasons. From the perspective of the sender’s MX, this usually results in a 550 status code (often given as “Relay access denied”). This is a hard-fail, in that it tells the upstream MX that the recipient they’re trying to reach is permanently unavailable. The upstream MX … Continue reading

Using Postfix with MySQL Stored Procedures? (Just Use Functions)

postfix_random

If you’re like me and want to use Postfix with a MySQL backend, you may have also wanted to be able to call stored procedures from Postfix. Unfortunately, MySQL stored procs return multiple resultsets while Postfix’s call to the MySQL C API can only process a single resultset.  I banged my head against the wall for a while until I realized that a function called from a SELECT statement would return a Postfix-friendly single resultset. For example, this would be a perfectly acceptable virtual alias map file: user = mailreader password = somepassword dbname = mail_config query = SELECT retval FROM (SELECT fnPostfixVirtualAliasMapGet(‘%s’) AS retval) t WHERE t.retval IS NOT NULL; hosts = 127.0.0.1 This is useful if, for example, … Continue reading