Red*_*ick 3 delphi exception-handling freepascal lazarus
我有一些用Lazarus / FreePascal编写的使用Synapse IMAPSend库单元的代码。我尝试通过SSL(IMAPS)登录到IMAP服务器,但调用Login失败。
我试过检查异常-没有抛出异常。
除了与适当的服务器和端口的TCP三向握手之外,Wireshark没有显示任何内容。
这是代码
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;
Run Code Online (Sandbox Code Playgroud)
这是此函数的String结果
IMAP login to red@10.0.0.16:993 ... IMAP Login failed.
Run Code Online (Sandbox Code Playgroud)
如SimaWB的答案和注释中所示Arioch 'The
mySynaDebug := TsynaDebug.Create;
imap.Sock.OnStatus := @MySynaDebug.HookStatus;
imap.Sock.OnMonitor := @MySynaDebug.HookMonitor;
Run Code Online (Sandbox Code Playgroud)
产生了一个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!
Run Code Online (Sandbox Code Playgroud)
所以我正在前进:-)
我有libssl32.dll和libeay32.dll我的项目文件夹,但会检查我有正确的版本,也做了与鸡内脏正确的事情。
我使用的是Lazarus的64位版本。OpenSSL DLL是Synapse的ssl_openssl单元动态加载的32位DLL。我安装了Lazarus / FPC的32位版本,现在我的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;
Run Code Online (Sandbox Code Playgroud)
然后,应用程序创建一个扩展名为“ .slog”的日志文件。也许您可以在日志文件中找到更多详细信息。