tags:

views:

95

answers:

0

I am building an SMTP server. I need to find the MX record of any domain name for this from the "to" email address and I am using res_search for this.

for example rcpt to:[email protected]

#define MAXLINE 100

int main()
{
    res_init();

    char ans[MAXLINE];

    res_search("www.yahoo.com",C_IN,T_MX,ans,MAXLINE);

    printf("%s",inet_ntoa(ans));

    return 0;
}

I get an output but it is not correct. Can you please point out the mistake.