MailBee.NET Objects 4.0

SmtpServer.Proxy Property

Provides access to the settings which allow MailBee to connect to a mail server via a proxy server.

public MailBee.Proxy.ProxyServer Proxy {get;}

Property Value

A reference to the proxy server settings.

Remarks

By default, proxy server is not used. The developer can change this to make MailBee use SOCKS4, SOCKS5, or HTTP proxy server. This is useful when a firewall prohibits direct connections with a mail server but permits connections via a proxy.

Example

This console sample establishes connection with the mail server via an HTTP proxy server which requires clients to authenticate themselves.

[C#]
using System;
using MailBee;
using MailBee.SmtpMail;
using MailBee.Proxy;

class Sample
{
    static void Main(string[] args)
    {
        Smtp mailer = new Smtp();
        SmtpServer server = new SmtpServer("mail.domain.com");
        server.Proxy.Name = "proxy.server.com";
        server.Proxy.Protocol = ProxyProtocol.Http;
        server.Proxy.Port = 808;
        server.Proxy.AccountName = "jdoe";
        server.Proxy.Password = "secret";
        mailer.SmtpServers.Add(server);
        mailer.Connect();
        Console.WriteLine("Connected via a proxy server");
        mailer.Disconnect();
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.SmtpMail
Imports MailBee.Proxy

Class Sample
    Shared Sub Main(ByVal args() As String)
        Dim mailer As Smtp = New Smtp
        Dim server As SmtpServer = New SmtpServer("mail.domain.com")
        server.Proxy.Name = "proxy.server.com"
        server.Proxy.Protocol = ProxyProtocol.Http
        server.Proxy.Port = 808
        server.Proxy.AccountName = "jdoe"
        server.Proxy.Password = "secret"
        mailer.SmtpServers.Add(server)
        mailer.Connect()
        Console.WriteLine("Connected via a proxy server")
        mailer.Disconnect()
    End Sub
End Class

See Also

SmtpServer Class | MailBee.SmtpMail Namespace