简体   繁体   English

使用Indy发送邮件而不使用外部服务器

[英]Sending mail with Indy without using external server

My apps send emails using the Indy TiDSMTP client component. 我的应用程序使用Indy TiDSMTP客户端组件发送电子邮件。 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. 但是,在某些情况下,客户无法或不愿意设置SMTP服务器和端口,用户名等,因此我希望提供一种发送电子邮件的解决方案,而无需任何人设置任何内容。

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 ''"). 我尝试了TIDSMTPRelay演示但是我需要explcitly输入DNS服务器IP地址(当我这样做时,它失败了“Project SMTPRelay.exe引发了异常类EIdHostRequired并带有消息''”)。 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. 我希望Indy解决方案不需要用户输入任何设置 - 只要他们可以访问互联网就可以“开箱即用”。

What else do I need to provide? 我还需要提供什么?

TIA, R TIA,R

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. 这需要执行DNS查找以检索每个收件人域的MX记录。 Indy's TIdSMTPRelay component handles that for you (by using the TIdDNSResolver component internally). Indy的TIdSMTPRelay组件为您处理(通过内部使用TIdDNSResolver组件)。

There is no platform-neutral way to query for the machine's current DNS configuration. 查询机器当前的DNS配置没有平台中立的方式。 That requires platform-specific APIs. 这需要特定于平台的API。 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. Indy现在没有任何东西来实现自动化,尽管我认为它不会超出未来版本的可能性范围。

The exception you are seeing is raised by TIdTCPClient.Connect() . 您看到的异常由TIdTCPClient.Connect()引发。 You should not be calling that manually when using TIdSMTPRelay . 使用TIdSMTPRelay时,不应该手动调用它。 It is called internally after determining which Host to connect to for each recipient domain. 在确定要为每个收件人域连接的Host之后,在内部调用它。 All you need to do yourself is set the DNSServer property, optionally set the RelaySender property, and then call the Send() method. 您需要自己设置DNSServer属性,可选地设置RelaySender属性,然后调用Send()方法。 Nothing else. 没有其他的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM