Chaman Zinga

i am writing an application in which it sends mail when user acknowledges something..

to make it more general..

i need to get smtp server address, but not from user..

is there any program i can write to query smtp mail address

and then send mail

let me know.

Re: Visual C++ Language getting SMTP server address


I don't think it's likely that's possible. Otherwise this functionality would also exist in normal e-mail clients like Outlook Express. But even in that software you always have to supply the SMTP server address yourself.

Re: Visual C++ Language getting SMTP server address


Given an email address, for example, you can perform a DNS lookup to retrieve the MX record for the domain ''. The DNS response will return the IP addresses of one or more SMTP mail servers that will accept mail for the domain.

Applications like Outlook do not perform DNS MX lookups. They expect to be configured with a known SMTP server address to which it will direct all email - for example an SMTP server address supplied by an ISP. The SMTP server will itself perform DNS MX lookups for all destination email domains it does not recognise and forward emails to the respective servers.

In short, you do not need to know any SMTP servers if you are prepared to write the DNS MX lookup code. The DNS protocol and packet format is widely documented on the web. Basically you construct and transmit UDP packets to a DNS server and decode the response from it.

Re: Visual C++ Language getting SMTP server address


This is a C++ langauge forum, and we aim to deal strictly with questions regarding the C++ language as implemented by VC8, and in addition the standard libraries (STL, CRT). While we do also cover quite a few borderline queries, as well as those completely off topic, I do feel that you should restrict the amount of non-C++ questions such as this.

For further questions related to networking, visit the similarly named newsgroup at