【问题标题】:How can the smtp/pop3 client reads the [error] message that the smtp/pop3 server has send to them (in delphi)?smtp/pop3 客户端如何读取 smtp/pop3 服务器发送给他们的 [error] 消息(在 delphi 中)?
【发布时间】:2014-05-22 11:20:13
【问题描述】:

我的服务器端 smtp 和 pop3 事件使用 ASender 发送 [错误] 消息:TIdCommand 如下:

ASender.Reply.SetReply(OK, 'message to send');

ASender.Reply.SetReply(ERR, 'error message to send');

所以我的问题是如何从 smtp/pop3 客户端读取此消息?

【问题讨论】:

  • 有没有办法让 POP3 客户端获取服务器没有响应或不工作的消息:尝试 POP3Client.connect;除了 // 如何阅读错误信息 ????结束;

标签: delphi email indy


【解决方案1】:

听起来您需要了解异常的工作原理。

如果Connect() 失败,则会引发异常。可能有几种不同的异常类型,包括 EIdSocketError,其中包含套接字错误代码。

如果 POP3/SMTP 命令失败,则会引发 EIdRFCReplyError 异常。异常包含服务器的响应代码和消息。此信息也可在组件的 LastCmdResult.CodeLastCmdResult.NumericCodeLastCmdResult.Text 属性中获得。

【讨论】:

  • 谢谢,Remy Lebeau - LastCmdResult.FormattedReply.Text 正是我所需要的 :)
  • 请勿阅读LastCmdResult.FormattedReply.Text。请改为阅读LastCmdResult.TextFormattedReply 用于生成和解析回复,而不是用于处理回复。
  • 您能否提供一些代码,SMTP 服务器如何向 SMTP 客户端发送错误消息以及客户端如何从事件中获取它: SMTPServerMsgReceive(ASender: TIdSMTPServerContext;AMsg: TStream; var LAction: TIdDataReply );到事件:SMTPClient.Send(myTidMessage);
  • @Roman_Bezjak:在OnMsgReceive 事件中,向客户端发送错误消息的唯一方法是将VAction 参数设置为dOk 以外的值,或者引发一个异常,TIdSMTPServer 然后将发送给客户端。无论哪种方式,在客户端,TIdSMTP.Sender() 将使用适当的CodeText 值引发EIdRFCReplyError 异常。
猜你喜欢
  • 2010-12-10
  • 2015-01-21
  • 1970-01-01
  • 2010-10-14
  • 1970-01-01
  • 1970-01-01
  • 2010-10-07
  • 2011-03-28
  • 2013-03-16
相关资源
最近更新 更多