Resolving email addresses

Lil_Guppy used Ask the Experts™
How can I resolve an email address to get the IP of the server. ie: how do I get the IP from, so I can send emails DIRECTLY to
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
For 500 points I will give you the code.  

Here is what you do:

1) Query the domain DNS and obtain the MX records for the domain.

2) Create a list of MX servers in order of priority

3) Loop throught the MX list and get the ip address for the first server

4) Try to connect to the server on port 25.

Your connection may not work unless the server you are sending from is listed in your own domain DNS.

You can download all the code you need from search for vbSendMail. There is a few bugs in the MX Query routine which you will need to debug and also the Sockets implementation has to be changed to use non blocking socekets otherwise some of the servers you connected to will cause your server to hang.


What exactly will your code do? I need something that will take the email address (ie, resolve it to the mail server, find one that will allow a connection, and optionally, verify that the email exists. After all of this, I need it to return the IP of the correct mail server for use in a WinSock connection (using the ocx because I dont know how to do it otherwise :P). If you can help me with that, then I will be extremely greatfull. Thanks
You could try to find some source code for an SMTP server on the net or you need to follows steps 1-4 above. A VB expert would need several days to do this job.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial