Delphi Pascal突触错误处理

Delphi Pascal突触错误处理,delphi,exception-handling,freepascal,lazarus,Delphi,Exception Handling,Freepascal,Lazarus,我有一些使用IMAPSend库单元编写的代码。我尝试通过SSL(IMAPS)登录IMAP服务器,但调用login失败 我已经尝试检查异常-没有抛出异常 Wireshark除了向适当的服务器和端口进行TCP三方握手之外,没有显示任何内容 这是密码 function GetImapResponse(host, port, user, pass:String): String; var response: String = ''; imap: TIMAPSend; no_unseen: i

我有一些使用
IMAPSend
库单元编写的代码。我尝试通过SSL(IMAPS)登录IMAP服务器,但调用
login
失败

我已经尝试检查异常-没有抛出异常

Wireshark除了向适当的服务器和端口进行TCP三方握手之外,没有显示任何内容

这是密码

function GetImapResponse(host, port, user, pass:String): String;
var
  response: String = '';
  imap: TIMAPSend;
  no_unseen: integer;
begin
  imap := TIMAPSend.create;
  try
    imap.TargetHost := host;  //'10.0.0.16';
    imap.TargetPort := port;  //'993';
    imap.UserName := user;    //'red';
    imap.Password := pass;    //'********';
    imap.AutoTLS := false;
    imap.FullSSL := true;
    response := response + 'IMAP login to '+user+'@'+host+':'+port+' ... ';
    if imap.Login then
    begin
      response := response + 'Logged in OK. ';
      // How many unseen?
      no_unseen := imap.StatusFolder('INBOX','UNSEEN');
      Form1.Label2.Caption := IntToStr(no_unseen);
      response := 'INBOX contains ' +  IntToStr(no_unseen) + ' unseen messages. ';
    end
    else
    begin
      response := response + 'IMAP Login failed. ';
    end;
  except
    on E: Exception do
    begin
      response := response + 'Exception: ' + E.Message;
      showMessage(response);
    end;
  end;
  {
  finally
    imap.free;
    response := response + 'Finally. ';
  end;
  }
  Result := response;
end;               
下面是这个函数的字符串结果

IMAP login to red@10.0.0.16:993 ... IMAP Login failed. 
问:有没有办法了解IMAPSend认为发生了什么的一些细节?
更新1 如
SimaWB
的回答和
Arioch的评论所示

  mySynaDebug := TsynaDebug.Create;
  imap.Sock.OnStatus := @MySynaDebug.HookStatus;
  imap.Sock.OnMonitor := @MySynaDebug.HookMonitor; 
生成了一个projectname.slog文件,其中包含

20130722-103643.605 0011F230HR_SocketClose: 
20130722-103643.609 0011F230HR_ResolvingBegin: 10.0.0.16:993
20130722-103643.620 0011F230HR_ResolvingEnd: 10.0.0.16:993
20130722-103643.623 0011F230HR_SocketCreate: IPv4
20130722-103643.628 0011F230HR_Connect: 10.0.0.16:993
20130722-103643.631 0011F230HR_Error: 10091,SSL/TLS support is not compiled!
因此,我向前迈进:-)

我的项目文件夹中确实有
libssl32.dll
libeay32.dll
,但我会检查是否有正确的版本,是否用鸡内脏做了正确的事情


更新2: 我使用的是64位版本的Lazarus。OpenSSL DLL是Synapse的ssl_OpenSSL单元动态加载的32位DLL。我安装了32位版本的Lazarus/FPC,现在我的IMAP/SSL客户端程序可以按预期编译和工作


目前的64位Lazarus/FPC二进制发行版(v1.0.10/2.6.2)似乎无法交叉编译到i386(我认为这可能会有所帮助)。

您尝试过Synapse的synadbg单位吗

imap := TIMAPSend.create;
imap.Sock.OnStatus := TSynaDebug.HookStatus;
imap.Sock.OnMonitor := TSynaDebug.HookMonitor;

然后应用程序创建一个扩展名为“.slog”的日志文件。可能您可以在日志文件中找到更多详细信息。

问题在这里:
imap.AutoTLS:=false;
imap.FullSSL:=true尝试将true设置为false,将false设置为true。。。

端口应为587

Ubuntu 64位上的.slog文件中的相同错误已通过“sudo apt get install libssl dev”修复,并在使用部分包含“ssl_openssl”。

synapse附带源代码。按imap上的F7(跟踪到)。登录
,并像调试程序的所有其他部分一样调试它。严格地说,仅供参考,->x86如果没有扩展类型,则无法工作。最初x86_64已被弃用,因此它被视为“没有”。PowerPC64->PowerPC32运行正常,这不是一般的64->32问题。我正在使用Delphi 10西雅图构建32位应用程序,但我收到了“10091,SSL/TLS支持未编译!”消息。有人用最新版本的Delphi对它进行了测试吗?这看起来很有用,但编译器抱怨
错误:为调用“HookStatus”指定的参数数目错误
,因此它认为我在调用而不是(比如)为过程分配引用。我找不到这种用法的任何例子-(然后
@imap.Sock.OnStatus:=@TSynaDebug.HookStatus;
imap.Sock.OnStatus:=@TSynaDebug.HookStatus;
?@Arioch'The:我无法找到一种不失败的方法
unit1.pas(95,26)错误:不兼容类型:获得“预期”
这意味着您应该创建一个TSynaDBG类型的对象,并采用该对象的方法,而不是class@RedGrittyBrick:可能是关于版本差异。