Example #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();
        }
 /// <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;
 }
Example #3
0
        /// <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));
            }
        }
        /// <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);
        }