GeoIP aware SMTP service – 2

The Theory

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, then lookup mx records of and DNS may return one or a list of mx records, maybe,….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.




1 thought on “GeoIP aware SMTP service – 2

Leave a Reply

Your email address will not be published. Required fields are marked *