tags:

views:

151

answers:

3

Is it possible to send e-mails using smtp through proxy with delphi. I have build some e-mail sending applications before, using SSL etc. but i didn't use proxy before, has anyone idea how i can do that with delphi.

Thanks.

+1  A: 

Use INDY components.

if proxy and it's type known in advance, then before sending email you have to authorize in proxy server (suppose, with TidTcpClient). Then with IdSmtp send email.

OR

if type proxy type unknown, try to use IdSocksInfo and IdIOHandlerSocket. Tune them to proxy and bind with idSMTP.

histrio
@histrio: the SMTP session has to be conducted on the same socket connection that is used to connect to the proxy. So your separate instructions really need to be rolled together. You cannot connect to an unknown proxy, but when you do connect, TIdSMTP has to use the same socket. Indy has built-in capabilities for that.
Remy Lebeau - TeamB
+2  A: 

The correct way to use a proxy with Indy's TIdSMTP component is to utilize the SocksInfo (Indy 9 and earlier) or TransparentProxy (Indy 10) property of TIdIOHandlerSocket.

For Indy 9 and earlier (only supports SOCKS v4/4a/5 proxies):

  1. Assign a TIdIOHandlerSocket component to the TIdSMTP.IOHandler property
  2. Assign a TIdSocksInfo component to the TIdIOHandlerSocket.SocksInfo property.

For Indy 10 (supports SOCKS, HTTP, and custom proxies):

  1. Assign a TIdIOHandlerStack component (derives from TIdIOHandlerSocket) to the TIdSMTP.IOHandler property
  2. Assign a TIdSocksInfo, TIdConnectThroughHttpProxy, or other TIdCustomTransparentProxy-derived component to the TIdIOHandlerSocket.TransparentProxy property.
Remy Lebeau - TeamB
A: 

If you did it before, did you use Indy or something else? Whatever component you have (Indy, ICS, others) either has Proxy support built in (look at the properties of your internet component set) or it doesn't. If it doesn't, consider "Overbyte ICS" or Indy.

I am not a big fan of Indy. I have used it, but then moved away to Francois Piette's Overbyte ICS components. Try both, if you're not currently using ICS.

This probably ISN'T the way you wanted to go (you said you wanted to use SMTP), but for the benefit of future people searching for ways to do things, I will also add that it is possible to use Windows MAPI integration to do this also, and have an email client program (Thunderbird, Outlook) send the message, from your current email client's "from address", to an email address of your choice, using TJvMail in the JVCL component set.

Warren P