Getting servers for sending mail via SMTP
I have looked in this article:
http://www.codeguru.com/Cpp/I-N/inte...icle.php/c6177
It shows how to send mail via SMTP.
However, in order to send email I need to connect to a server via mail.connect().
My question is, how do I get the available server on the computer the program runs (the client)?
Thanks in advance.
Re: Getting servers for sending mail via SMTP
Well, how do you know who the message is coming from? Either it is predefined, in which case you should already know the SMTP server or you need to get a "From" address from the user at which time you would need to get the SMTP connect info from the user as well.
Re: Getting servers for sending mail via SMTP
Re: Getting servers for sending mail via SMTP
It can be done.
You should extract the FQDN (domain name) of the recipient mail address, and then lookup its MX record (in DNS). The MX record contains a hostname which is resolved into an IP for the recipient's mail server (SMTP).
NOTE: For security reasons, most SMTP servers will perform a reverse DNS lookup of the calling IP address and then use the FQDN to lookup the MX. If the calling IP doesn't have a MX record, it will most likely reject it.