예제 #1
0
        /// <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>
        /// Is called when email domain target servers resolve operation has completed.
        /// </summary>
        /// <param name="to">RCPT TO: address.</param>
        /// <param name="op">Asynchronous operation.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>to</b> or <b>op</b> is null reference.</exception>
        private void EmailHostsResolveCompleted(string to,Dns_Client.GetEmailHostsAsyncOP op)
        {
            if(to == null){
                throw new ArgumentNullException("to");
            }
            if(op == null){
                throw new ArgumentNullException("op");
            }

            if(op.Error != null){
                LogText("Failed to resolve email domain for email address '" + to + "' with error: " + op.Error.Message + ".");

                Dispose(op.Error);
            }
            else{
                StringBuilder buf = new StringBuilder();
                foreach(HostEntry host in op.Hosts){
                    foreach(IPAddress ip in host.Addresses){
                        m_pTargets.Add(new Relay_Target(host.HostName,new IPEndPoint(ip,25)));
                    }
                    buf.Append(host.HostName + " ");
                }
                LogText("Resolved to following email hosts: (" + buf.ToString().TrimEnd() + ").");

                BeginConnect();
            }

            op.Dispose();
        }