Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending mail through http proxy

I'm trying to send emails from a system that connects to internet through a http proxy which is set in Internet Options.

i'm using SmtpClient.

Is there any way to send mails with SmtpClient through this proxy setting. Thanks

like image 914
Salar Avatar asked May 10 '09 06:05

Salar


3 Answers

Http Proxies control http traffic, they rarely have anything to do with SMTP at all. I've never heard of proxying SMTP before after all SMTP itself is intrinsically supports a chain of "proxies" to the destination SMTP server.

like image 125
AnthonyWJones Avatar answered Sep 20 '22 02:09

AnthonyWJones


I understand that you want to use the browsers default settings, i would also like an answer for that.

Meanwhile, you could do it manually.

    MailAddress from = new MailAddress("[email protected]");
    MailAddress to = new MailAddress("[email protected]");

    MailMessage mm = new MailMessage(from, to);
    mm.Subject = "Subject"
    mm.Body = "Body";

    SmtpClient client = new SmtpClient("proxy.mailserver.com", 8080);
    client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");

    client.Send(mm);
like image 45
bahith Avatar answered Sep 21 '22 02:09

bahith


If the only access you have to the internet is through HTTP, then pretty much the only way you'll be able to do this is by setting up a VPS (or equiv) with SSH on port 443 and using corkscrew (or putty) to tunnel ssh through. From there it is a simple matter to forward smtp traffic over your ssh tunnel.

Be aware that you may be violating the companies computing policy if you do this.

like image 40
Luke Chadwick Avatar answered Sep 22 '22 02:09

Luke Chadwick