Reputation: 5620
My apps send emails using the Indy TiDSMTP client component. In some situations however, the customers are not able or willing to set up SMTP servers and ports, usernames, etc, so I would like to provide a solution that sends emails without requiring anybody to set up anything.
I tried the TIDSMTPRelay demo but I need to enter DNS server IP address explcitly (and when I did this, it failed on "Project SMTPRelay.exe raised exception class EIdHostRequired with message ''"). I was hoping for an Indy solution that doesn't require the user to enter any settings - one that will work "out of the box" as long as they have access to the internet.
What else do I need to provide?
TIA, R
Upvotes: 4
Views: 4229
Reputation: 595712
You have to send the emails to the recipient mail servers directly. That requires performing a DNS lookup to retreive the MX records for each recipient domain. Indy's TIdSMTPRelay
component handles that for you (by using the TIdDNSResolver
component internally).
There is no platform-neutral way to query for the machine's current DNS configuration. That requires platform-specific APIs. Indy does not have anything in place right now to automate that, though I suppose it is not outside the realm of possibility in a future release.
The exception you are seeing is raised by TIdTCPClient.Connect()
. You should not be calling that manually when using TIdSMTPRelay
. It is called internally after determining which Host
to connect to for each recipient domain. All you need to do yourself is set the DNSServer
property, optionally set the RelaySender
property, and then call the Send()
method. Nothing else.
Upvotes: 12