For an Indy 10 IMAPClient with an existing IOHandler derived from TIdIOHandlerStack, attach SOCKS information before calling Connect:

ProxyInfo := TIdSocksInfo.Create(IMAPClient);
ProxyInfo.Version := svSocks5;
ProxyInfo.Host := 'proxy.example';
ProxyInfo.Port := 1080;

(IMAPClient.IOHandler as TIdIOHandlerStack).TransparentProxy := ProxyInfo;

The types come from IdSocks and IdIOHandlerStack. If no IOHandler exists yet, create and assign the handler appropriate for the mail connection first.

Preserve an already configured SSL IOHandler. Replacing it with a plain stack handler can remove TLS; TransparentProxy only supplies proxy negotiation, not implicit TLS on 993 or STARTTLS on 143.

The fragment assumes unauthenticated SOCKS5. For a public mail server, the SOCKS5 proxy list supplies candidates; confirm that the selected endpoint permits the required IMAP host and port. For a proxy account, configure TIdSocksInfo's authentication, username and password separately from the IMAP account.

ProxyInfo.Host names the intermediary. IMAPClient.Host remains the mail service with its intended TLS identity and certificate-validation policy.

متعلقہ مضامین