General-Purpose Mail Filter
The geolocation functions allow you to identify the country where
the given IP address or host name is located. These functions are
available only if the ‘GeoIP’ library is installed and
mailfromd is compiled with the ‘GeoIP’ support. The
m4 macro ‘WITH_GEOIP’ is defined if it is so.
The GeoIP is a geolocational package distributed by ‘MaxMind’ under the terms of the GNU Lesser General Public License. The library is available from http://www.maxmind.com/app/c.
Look up the ‘ISO 3166-1’ country code corresponding to the IP address ip. If tlc is given and is not zero, return the 3 letter code, otherwise return the 2 letter code.
Look up the ‘ISO 3166-1’ country code corresponding to the host name name. If tlc is given and is not zero, return the 3 letter code, otherwise return the 2 letter code.
If it is impossible to locate the country, both functions raise the
e_not_found exception. If an error internal to the
‘GeoIP’ library occurs, they raise the
Applications may test whether the GeoIP support is present and
enable corresponding code blocks conditionally by testing if
the ‘WITH_GEOIP’ m4 macro is defined. For example, the
following code adds to the message the ‘X-Originator-Country’
header, containing the 2 letter code of the country where the client
machine is located. If
mailfromd is compiled without
‘GeoIP’ support, it does nothing:
m4_ifdef(`WITH_GEOIP',` header_add("X-Originator-Country", geoip_country_code_by_addr($client_addr)) ')
This document was generated on January 3, 2019 using makeinfo.Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.