0

I use the following code for SMTP:

            MailMessage mail = new MailMessage();
            mail.From = new System.Net.Mail.MailAddress(Global.username);
            mail.Subject = Global.subject;

            SmtpClient smtp = new SmtpClient();
            smtp.Port = 587;
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new NetworkCredential(Global.username, Global.password); 
            smtp.Host = "smtp.gmail.com";

            mail.To.Add(new MailAddress(Global.to));

            mail.IsBodyHtml = true;
            mail.Subject = Global.subject;
            mail.Body = Global.message;
            smtp.Send(mail);

That works perfectly, but the problem is I need HTTP and Socks proxy support. I'm looking for ether free libraries that I can use for commercial purposes or what approach should I do to get proxies running. I also need this for POP3 and IMAP, I'm thinking it will be easier to write my own wrappers than finding something already out there, I'm just not sure where to start. I have got my own HTTP wrapper done with HTTP and Socks support, but I'm not sure how SMTP, IMAP and POP3 works through proxy.. Whats the best way for me to get this done? Thanks!

4

2 回答 2

3

使用CNTLM怎么样?我以前在 Python 中使用过它,但我还没有在其他编程语言中尝试过它。

于 2013-01-20T04:48:36.793 回答
1

Socks 支持需要嵌入到 SMTP 类本身(或者至少是它管理套接字连接的部分),这里不是这种情况。你有两个选择:

  1. 使用一个替代品MailMessage,它支持内置的 SOCKS
  2. 或者,您需要使用 SOCKS 代理/隧道应用程序或类,它将在本地系统上打开一个侦听套接字并接受其上的连接。然后它将充当 SOCKS 客户端并通过两种方式传递数据。您将设置您的MailMessage实例以使用此本地端口,并且将正确包装数据以供您通过 SOCKS。
于 2013-01-18T06:27:31.043 回答