Thursday, June 7, 2007

Configuring your DNS server for inet_res.

When using inet_res, you must configure a DNS server to query, this could be done like this:


-define(MASTER_DNS, {212,XX,XX,252}).

init() ->
inet_db:add_ns(?MASTER_DNS).



Once you've called your ?MODULE:init/1 you're able to use your ?MODULE:get_mx/1 function.


node> mail:init().
ok

node> mail:get_mx("yahoo.com").
[{1,"e.mx.mail.yahoo.com"},
{1,"a.mx.mail.yahoo.com"},
{1,"b.mx.mail.yahoo.com"},
{1,"c.mx.mail.yahoo.com"},
{1,"d.mx.mail.yahoo.com"},
{1,"f.mx.mail.yahoo.com"},
{1,"g.mx.mail.yahoo.com"}]


The result is a list of tuples, the first element is the server weight, the second the server name :p

No comments:

Sticky