SMTP problem

Hi!

I went through an emailing tutorial, and ended up with the code below. But it doesn’t work. I get no compiler errors/warnings, nor runtime errors. Though it doesn’t send the email. Could someone please checkout the code and see what’s wrong?
Thanks a lot.

gethostbyname will return the A records for a domain. To find the mail server for a domain you must request the MX records. This will return zero or more mail server domains (you should use the one with the lowest preference). You can then use gethostbyname to retrieve the IP address for the mail server (this is often included in the original response as a matter of efficiency). Winsock does not provide MX lookup functionality. However, Windows 2000 and above include a DNS API. Alternatively, there is code on the web that implements a DNS client. For temporary testing, you can use a web page to look up the MX servers.

Sample code that uses the Windows DNS API to query the MX records for yahoo.com:

>> So, does it simply means that I can use "mx3.mail.yahoo.com" as yahoo's address, since it's the lowest in preference list <<

Yes, but only for the next 770 seconds as specified by the time-to-live value. After that, it may change (although in reality it probably only changes occasionally). If mx3 does not work you should try the other servers in order of preference.