clientSocket1.host := 'smtp.machine';
clientsocket1.port := 25;
clientsocket1.clienttype := ctblock;
clientsocket1.open;
sCommand := 'some smtp command';
clientsocket1.sendbuf(PChar(sCommand), length(sCommand));
发送完命令后,准备接收信息。
写个线程对它返回的结果进行接受。
procedure TMyThread.Execute;
var
Event: THandle;
begin
Event := WSACreateEvent;
WSAEventSelect(clientSocket1.Socket.SocketHandle, Event, False, FD_READ or FD_CLOSE);
case MsgWaitForMutipleObjects(1, False, Event, TimeOut, QS_ALLINPUT) of
WAIT_OBJECT_0:
begin
WSAResetEvent(Event);
Count := ClientSocket1.Socket.ReciveBuf(Buffer, Count);
//PostMessage(Form1.Handle, WM_RecvBuffer, Count, Integer(Buffer));
end;
end;
WSACloseEvent(Event);
end;
end;