public override IReadOnlyMailItem GetNextMailItem() { if (this.mailItemSentForProcessing) { return(null); } if (this.getMailItemBeingCalledForTheFirstTime) { SmtpMailItemNextHopConnection.InitializeSmtpLatencyTracking(this.mailItem.LatencyTracker); this.getMailItemBeingCalledForTheFirstTime = false; } return(this.mailItem); }
public override void AckConnection(MessageTrackingSource messageTrackingSource, string messageTrackingSourceContext, AckStatus status, SmtpResponse smtpResponse, AckDetails details, TimeSpan?retryInterval, bool resubmitWithoutHighAvailablityRouting, SessionSetupFailureReason failureReason) { switch (status) { case AckStatus.Pending: case AckStatus.Skip: throw new InvalidOperationException("Invalid status"); case AckStatus.Success: case AckStatus.Retry: case AckStatus.Fail: case AckStatus.Resubmit: if (this.result == null) { this.result = new SmtpMailItemResult(); } this.result.ConnectionResponse = new AckStatusAndResponse(status, smtpResponse); if (details != null) { this.result.RemoteHostName = details.RemoteHostName; } if (this.notificationHandler != null) { this.notificationHandler.AckConnection(status, smtpResponse); } SmtpMailItemNextHopConnection.EndSmtpLatencyTracking(this.mailItem.LatencyTracker); if (this.autoResetEvent != null) { this.autoResetEvent.Set(); return; } break; case AckStatus.Expand: case AckStatus.Relay: case AckStatus.SuccessNoDsn: case AckStatus.Quarantine: break; default: return; } }
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); }