Search code examples
c#proxysmtpclienthttp-proxy

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


Solution

  • 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);