Link to home
Start Free TrialLog in
Avatar of winexec
winexec

asked on

MX servers

Good day,

I want to find the MX servers for specific domains. By example, for hushmail.com the server is smtp.hushmail.com, for hotmail.com is mx1.hotmail.com etc.

I searched on the web and I found I have to use the function GetNetworkParams (on 2000, XP). Does anyone know an example?

Thank you,
W.
Avatar of RadikalQ3
RadikalQ3
Flag of Spain image

Hi!,
You have an example of use of this function via the jedi project iphelper api wrapper in:

https://www.experts-exchange.com/questions/20771226/Obtain-DNS-Server-addresses-auomatically.html
or... you can make with Indy component id IdDNSResolver, as resolved in the question:

https://www.experts-exchange.com/questions/20903774/IndyClients-Delphi-7.html?query=IdDNSResolver&topics=85
Avatar of winexec
winexec

ASKER

Thanks RadikalQ3,

I looked at the jedi example, but I don't know how to use it for my purpose.

The example below (found on the link you posted) does nothing, the memo remain clean. Besides, how can I use it to find the MX for hushmail.com?

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, iphlpapi, iptypes, StdCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;
   Memo1: TMemo;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  info: PFixedInfo;
  Buflen: cardinal;
begin
  Buflen := 1024;
  GetMem(info, BufLen);
  try
    GetNetworkParams(info, BufLen);
    memo1.Lines.Add(info.DnsServerList.IpAddress.S);
  finally
    FreeMem(info);
  end;
end;

end.

Thankx,  W.

P.S. I prefer not to use Indy, I don't even have the components installed.  
ASKER CERTIFIED SOLUTION
Avatar of AFZDeveloper
AFZDeveloper

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of winexec

ASKER

OK, i downloaded Synapse, but what exactly should I write in the place of "dns host name or ip address"

Thankx,
W.
ip or name of dns server(the computer that dns service running on it)
Commonly then domain name is dns server.
for example in our lan:
dns server is: 172.20.20.21
domain is: test.com
and when i run the my code
return "mail.test.com" in memo1.lines
---------------------------------------------
ex.:
 GetMailServers('yahoo.com','yahoo.com',Memo1.Lines);
Avatar of winexec

ASKER

Thanks, but it doesn't work :(  The memo remains empty.

Are you sure it's working for you?

W.
yes its work.
see the result of command "ipconfig /all"
and set the dns host server to one of  server listed on dns servers

are you on behind of proxy and the doamin you need the mx record of it, out side of your lan?
are you computer has valid ip over internet?

Avatar of winexec

ASKER

i am in a VPN, i tried to use the DNS found with ipconfig and didn't work, afterwards I connected with diaup and tried again, it didn't work :(
Avatar of winexec

ASKER

i forgot to say: i tried to find the MX for yahoo.com
i am not test 'yahoo.com' only for example i set it .
i am test my code on our LAN.
GetMailServers('ns1.yahoo.com','yahoo.com',Memo1.Lines);

works for me.

replace ns1.yahoo.com with your isp dns.
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept AFZDeveloper's comment as answer.

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Jacco
EE Cleanup Volunteer