Postfix support multiple transports by lookup mapping table. I need to setup a mapping table for IP->Country->Transport lookup.
+-------------+ To China?--->[China Relay Host] email-->| Central Hub |>--< +-------------+ Overseas?-->[Overseas Relay Host]
Central Hub is a postfix server that used to analyze the recipient address to identify email destination geographical location, above example indicated that, When destination of the email locate in Mainland China, will forward to the relay host in China. Otherwise goes to default.
How to get email domain geographical location?
I’ll split the email address into two part, e.g. [email protected] -> recipient: ronpoon and domain:fakedomain.com, then lookup mx records of fakedomain.com and DNS may return one or a list of mx records, maybe mx1.fakedomain.com, mx2.fakedomain.com….etc. I randomly pick one of them and lookup GeoIP table and get a ISO 3166 Country Code, and find transport for the country.
Between Central Hub and both relay hosts, we will use QMQP to pass email to relay host. And of course, we may establish VPN between them.