How can a proxy be connected (http \ s | socks4 \ 5). There is such a method:

static void Send(string login, string password , string mailSend, string subject , string body , string proxyHost, int proxyPort) { SmtpClient smtp = new SmtpClient("smtp.mail.ru", 587); smtp.Credentials = new System.Net.NetworkCredential(login, password); MailMessage mail = new MailMessage(); mail.From = new MailAddress(login); mail.To.Add(new MailAddress(mailSend)); mail.Subject = subject; mail.Body = body; smtp.EnableSsl = true; smtp.Send(mail); } 

Is it possible at all? Tried some decisions made on SO, but did not help.

  • It is necessary to specify a programming language. In general, look at the documentation for the SmtpClient class, most likely the proxy support should be built into it in order for it to work - Mike
  • I apologize, added to the topic header yap) - GetResult
  • stackoverflow.com/questions/844835/… and watching here - Roman Ieromenko
  • Yes, I did, but it says that a proxy has already been set up in the Internet connection settings, but I would like to connect / send a letter through a proxy without changing the network settings, maybe there are some other ways to send a letter, where is it possible to install proxies? - GetResult
  • And then look emailarchitect.net/easendmail/sdk/html/… - Roman Ieromenko

1 answer 1

Repository: https://github.com/Zergatul/ZergatulLib project Zergatul

Example of sending mail:

 var smtp = new SmtpConnection(); smtp.Proxy = new HttpProxy("ip-адрес", 8080); smtp.Connect("smtp.mail.ru", 587); smtp.ExtendedHello("mail.ru"); smtp.StartTls("mail.ru"); smtp.ExtendedHello("mail.ru"); smtp.AuthPlain("mail_acc", "password"); smtp.Mail("mail_acc@mail.ru"); smtp.Recipient("recipient@gmail.com"); smtp.Data(EmailFormatter.GetText("Bill Gates <mail_acc@mail.ru>", "Subject", "Steve Jobs <recipient@gmail.com>", "Hello")); //smtp.Data(EmailFormatter.GetHtml("Bill Gates <mail_acc@mail.ru>", "Subject", "Steve Jobs <recipient@gmail.com>", "<h1>Hello!</h1><a href='stackoverflow.com'>click!</a>")); smtp.Quit(); 

It is possible to send text and html-messages. SMTP protocol and proxy classes are very simple, you can "move" my classes to your project.

HttpsProxy class was not tested on a real proxy, I either do not understand how it works, or could not find a real https proxy.