public SmtpMailItemNextHopConnection(NextHopSolutionKey key, IReadOnlyMailItem mailItem, ISmtpMailItemSenderNotifications notificationHandler) : base(null, 0L, DeliveryPriority.Normal, null)
 {
     this.key                    = key;
     this.mailItem               = mailItem;
     this.readyRecipients        = this.GetReadyRecipients();
     this.recipientsPending      = this.readyRecipients.Count;
     this.recipientEnumerator    = this.mailItem.Recipients.GetEnumerator();
     this.recipientEnumeratorAck = this.mailItem.Recipients.GetEnumerator();
     this.notificationHandler    = notificationHandler;
 }
Ejemplo n.º 2
0
        public SmtpMailItemResult Send(IReadOnlyMailItem readOnlyMailItem, bool useLocalHubOnly, TimeSpan waitTimeOut, ISmtpMailItemSenderNotifications notificationHandler)
        {
            if (readOnlyMailItem == null)
            {
                throw new ArgumentNullException("readOnlyMailItem");
            }
            IEnumerable <INextHopServer> enumerable;

            if (useLocalHubOnly)
            {
                string text = SmtpMailItemSender.LocalFQDN;
                bool   flag = SmtpMailItemSender.IsFrontendAndHubColocatedServer;
                if (string.IsNullOrEmpty(text))
                {
                    throw new InvalidOperationException("Email is unable to be sent because the name of the local machine can not be detemined.");
                }
                enumerable = new List <INextHopServer>();
                ((List <INextHopServer>)enumerable).Add(new NextHopFqdn(text, flag));
            }
            else
            {
                LatencyTracker.BeginTrackLatency(LatencyComponent.MailboxTransportSubmissionStoreDriverSubmissionHubSelector, readOnlyMailItem.LatencyTracker);
                if (!Components.ProxyHubSelectorComponent.ProxyHubSelector.TrySelectHubServers(readOnlyMailItem, out enumerable))
                {
                    throw new InvalidOperationException("Email is unable to be sent because Hub Selector didn't return any HUBs.");
                }
                LatencyTracker.EndTrackLatency(LatencyComponent.MailboxTransportSubmissionStoreDriverSubmissionHubSelector, readOnlyMailItem.LatencyTracker);
            }
            NextHopSolutionKey key = new NextHopSolutionKey(NextHopType.Empty, "MailboxTransportSubmissionInternalProxy", Guid.Empty);
            SmtpMailItemResult smtpMailItemResult;

            using (SmtpMailItemNextHopConnection smtpMailItemNextHopConnection = new SmtpMailItemNextHopConnection(key, readOnlyMailItem, notificationHandler))
            {
                LatencyTracker.BeginTrackLatency(LatencyComponent.MailboxTransportSubmissionStoreDriverSubmissionSmtpOut, readOnlyMailItem.LatencyTracker);
                Components.SmtpOutConnectionHandler.HandleProxyConnection(smtpMailItemNextHopConnection, enumerable, true, null);
                smtpMailItemNextHopConnection.AckConnectionEvent.WaitOne(waitTimeOut);
                LatencyTracker.EndTrackLatency(LatencyComponent.MailboxTransportSubmissionStoreDriverSubmissionSmtpOut, readOnlyMailItem.LatencyTracker);
                smtpMailItemResult = smtpMailItemNextHopConnection.SmtpMailItemResult;
            }
            return(smtpMailItemResult);
        }