/// <summary>
        /// Is called when smart hosts ip addresses resolve operation has completed.
        /// </summary>
        /// <param name="op">Asynchronous operation.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>op</b> is null reference.</exception>
        private void SmartHostsResolveCompleted(Dns_Client.GetHostsAddressesAsyncOP op)
        {
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            if (op.Error != null)
            {
                LogText("Failed to resolve relay smart host(s) ip addresses with error: " + op.Error.Message + ".");

                Dispose(op.Error);
            }
            else
            {
                for (int i = 0; i < op.HostEntries.Length; i++)
                {
                    Relay_SmartHost smartHost = m_pSmartHosts[i];

                    foreach (IPAddress ip in op.HostEntries[i].Addresses)
                    {
                        m_pTargets.Add(new Relay_Target(smartHost.Host, new IPEndPoint(ip, smartHost.Port), smartHost.SslMode, smartHost.UserName, smartHost.Password));
                    }
                }

                BeginConnect();
            }

            op.Dispose();
        }
예제 #2
0
        /// <summary>
        /// Smart host relay session constructor.
        /// </summary>
        /// <param name="server">Owner relay server.</param>
        /// <param name="localBindInfo">Local bind info.</param>
        /// <param name="realyItem">Relay item.</param>
        /// <param name="smartHosts">Smart hosts.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>server</b>,<b>localBindInfo</b>,<b>realyItem</b> or <b>smartHosts</b>is null.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        internal Relay_Session(Relay_Server server,IPBindInfo localBindInfo,Relay_QueueItem realyItem,Relay_SmartHost[] smartHosts)
        {
            if(server == null){
                throw new ArgumentNullException("server");
            }
            if(localBindInfo == null){
                throw new ArgumentNullException("localBindInfo");
            }
            if(realyItem == null){
                throw new ArgumentNullException("realyItem");
            }
            if(smartHosts == null){
                throw new ArgumentNullException("smartHosts");
            }

            m_pServer        = server;
            m_pLocalBindInfo = localBindInfo;
            m_pRelayItem     = realyItem;
            m_pSmartHosts    = smartHosts;

            m_RelayMode         = Relay_Mode.SmartHost;
            m_SessionID         = Guid.NewGuid().ToString();
            m_SessionCreateTime = DateTime.Now;
            m_pTargets          = new List<Relay_Target>();
            m_pSmtpClient       = new SMTP_Client();

            m_pSmtpClient.BdatEnabled = false;
        }
예제 #3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="queue">Item owner queue.</param>
 /// <param name="targetServer">Gets server where to send message. Value null means target server will be resolved by relay server.</param>
 /// <param name="from">Sender address.</param>
 /// <param name="envelopeID">Envelope ID_(MAIL FROM: ENVID).</param>
 /// <param name="ret">Specifies what parts of message are returned in DSN report.</param>
 /// <param name="to">Target recipient address.</param>
 /// <param name="originalRecipient">Original recipient(RCPT TO: ORCPT).</param>
 /// <param name="notify">DSN notify condition.</param>
 /// <param name="messageID">Message ID.</param>
 /// <param name="message">Raw mime message. Message reading starts from current position.</param>
 /// <param name="tag">User data.</param>
 internal Relay_QueueItem(Relay_Queue queue, Relay_SmartHost targetServer, string from, string envelopeID, SMTP_DSN_Ret ret, string to, string originalRecipient, SMTP_DSN_Notify notify, string messageID, Stream message, object tag)
 {
     m_pQueue            = queue;
     m_pTargetServer     = targetServer;
     m_From              = from;
     m_EnvelopeID        = envelopeID;
     m_DSN_Ret           = ret;
     m_To                = to;
     m_OriginalRecipient = originalRecipient;
     m_DSN_Notify        = notify;
     m_MessageID         = messageID;
     m_pMessageStream    = message;
     m_pTag              = tag;
 }
예제 #4
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="sysSettings">Reference to system settings.</param>
 /// <param name="relayMode">Relay mode.</param>
 /// <param name="smartHostBalanceMode">Specifies how smart hosts will balance.</param>
 /// <param name="smartHosts">Smart hosts.</param>
 /// <param name="idleTimeout">Session idle timeout seconds.</param>
 /// <param name="maxConnections">Maximum conncurent conncetions.</param>
 /// <param name="maxConnectionsPerIP">Maximum conncurent conncetions to one IP address.</param>
 /// <param name="relayInterval">Relay messages interval seconds.</param>
 /// <param name="relayRetryInterval">Relay retry messages interval seconds.</param>
 /// <param name="undeliveredWarning">Specifies after how many minutes delayed delivery message is sent.</param>
 /// <param name="undelivered">Specifies after how many hours undelivered notification message is sent.</param>
 /// <param name="storeUndelivered">Specifies if undelivered messages are stored to "Undelivered" folder in mail store.</param>
 /// <param name="bindings">Specifies SMTP listening info.</param>
 internal Relay_Settings(System_Settings sysSettings,Relay_Mode relayMode,BalanceMode smartHostBalanceMode,Relay_SmartHost[] smartHosts,int idleTimeout,int maxConnections,int maxConnectionsPerIP,int relayInterval,int relayRetryInterval,int undeliveredWarning,int undelivered,bool storeUndelivered,IPBindInfo[] bindings)
 {
     m_pSysSettings          = sysSettings;
     m_RelayMode             = relayMode;
     m_SmartHostsBalanceMode = smartHostBalanceMode;
     m_pSmartHosts           = smartHosts;
     m_IdleTimeout           = idleTimeout;
     m_MaxConnections        = maxConnections;
     m_MaxConnectionsPerIP   = maxConnectionsPerIP;
     m_RelayInterval         = relayInterval;
     m_RelayRetryInterval    = relayRetryInterval;
     m_SendUndelWaringAfter  = undeliveredWarning;
     m_SendUndeliveredAfter  = undelivered;
     m_StoreUndeliveredMsgs  = storeUndelivered;
     m_pBinds                = bindings;
 }
예제 #5
0
        /// <summary>
        /// Edit constructor.
        /// </summary>
        /// <param name="smartHost">Smart host.</param>
        public wfrm_System_SmartHost(Relay_SmartHost smartHost)
        {
            InitUI();

            m_pServer.Text = smartHost.Host;
            m_pPort.Value = smartHost.Port;
            if(smartHost.SslMode == SslMode.None){
                m_pSslMode.SelectedIndex = 0;
            }
            else if(smartHost.SslMode == SslMode.SSL){
                m_pSslMode.SelectedIndex = 1;
            }
            else if(smartHost.SslMode == SslMode.TLS){
                m_pSslMode.SelectedIndex = 2;
            }
            m_pUserName.Text = smartHost.UserName;
            m_pPassword.Text = smartHost.Password;
        }
        /// <summary>
        /// Queues message for relay.
        /// </summary>
        /// <param name="targetServer">Gets server where to send message. Value null means target server will be resolved by relay server.</param>
        /// <param name="from">Sender address.</param>
        /// <param name="envelopeID">Envelope ID_(MAIL FROM: ENVID).</param>
        /// <param name="ret">Specifies what parts of message are returned in DSN report.</param>
        /// <param name="to">Target recipient address.</param>
        /// <param name="originalRecipient">Original recipient(RCPT TO: ORCPT).</param>
        /// <param name="notify">DSN notify condition.</param>
        /// <param name="messageID">Message ID.</param>
        /// <param name="message">Raw mime message. Message reading starts from current position.</param>
        /// <param name="tag">User data.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>to</b>,<b>to</b>,<b>messageID</b> or <b>message</b> is null.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public void QueueMessage(Relay_SmartHost targetServer, string from, string envelopeID, SMTP_DSN_Ret ret, string to, string originalRecipient, SMTP_DSN_Notify notify, string messageID, Stream message, object tag)
        {
            if (messageID == null)
            {
                throw new ArgumentNullException("messageID");
            }
            if (messageID == "")
            {
                throw new ArgumentException("Argument 'messageID' value must be specified.");
            }
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            lock (m_pQueue){
                m_pQueue.Enqueue(new Relay_QueueItem(this, targetServer, from, envelopeID, ret, to, originalRecipient, notify, messageID, message, tag));
            }
        }
예제 #7
0
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>Returns true if two objects are equal.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is Relay_SmartHost))
            {
                return(false);
            }

            Relay_SmartHost smartHost = (Relay_SmartHost)obj;

            if (m_Host != smartHost.Host)
            {
                return(false);
            }
            else if (m_Port != smartHost.Port)
            {
                return(false);
            }
            else if (m_SslMode != smartHost.SslMode)
            {
                return(false);
            }
            else if (m_UserName != smartHost.UserName)
            {
                return(false);
            }
            else if (m_Password != smartHost.Password)
            {
                return(false);
            }

            return(true);
        }