Ejemplo n.º 1
0
Archivo: DSN.cs Proyecto: DM-TOR/nhin-d
        internal DSN(MimeEntity explanation, HeaderCollection fields, IEnumerable<HeaderCollection> perRecipientCollection)
        {
            m_explanation = explanation;

            m_perMessage = new DSNPerMessage(fields);

            m_perRecipients = new List<DSNPerRecipient>();
            foreach (HeaderCollection perRecipientFields in perRecipientCollection)
            {
                m_perRecipients.Add(new DSNPerRecipient(perRecipientFields));
            }
        }
Ejemplo n.º 2
0
Archivo: DSN.cs Proyecto: DM-TOR/nhin-d
        /// <summary>
        /// Initializes a new instance of the supplied DSN parts.
        /// </summary>
        public DSN(DSNPerMessage perMessage, IEnumerable<DSNPerRecipient> perRecipient)
            : base(DSNStandard.MediaType.DSNReport)
        {
            m_explanation = new MimeEntity();
            m_explanation.ContentType = MimeStandard.MediaType.TextPlain;

            m_notification = new MimeEntity();
            m_notification.ContentType = DSNStandard.MediaType.DSNDeliveryStatus;
            
            PerRecipient = perRecipient;
            PerMessage = perMessage;
        }
Ejemplo n.º 3
0
        internal DSN(MimeEntity explanation, HeaderCollection fields, IEnumerable <HeaderCollection> perRecipientCollection)
        {
            m_explanation = explanation;

            m_perMessage = new DSNPerMessage(fields);

            m_perRecipients = new List <DSNPerRecipient>();
            foreach (HeaderCollection perRecipientFields in perRecipientCollection)
            {
                m_perRecipients.Add(new DSNPerRecipient(perRecipientFields));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the supplied DSN parts.
        /// </summary>
        public DSN(DSNPerMessage perMessage, IEnumerable <DSNPerRecipient> perRecipient)
            : base(DSNStandard.MediaType.DSNReport)
        {
            m_explanation             = new MimeEntity();
            m_explanation.ContentType = MimeStandard.MediaType.TextPlain;

            m_notification             = new MimeEntity();
            m_notification.ContentType = DSNStandard.MediaType.DSNDeliveryStatus;

            PerRecipient = perRecipient;
            PerMessage   = perMessage;
        }
Ejemplo n.º 5
0
 static DSNMessage CreateNotificationMessage(Mdn mdn, TimeoutSettings settings)
 {
     var perMessage = new DSNPerMessage(settings.ProductName, mdn.MessageId);
     var perRecipient = new DSNPerRecipient(DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent
                                            , DSNStandard.DSNStatus.NETWORK_EXPIRED_PROCESSED,
                                            MailParser.ParseMailAddress(mdn.Recipient));
     //
     // The nature of Mdn storage in config store does not result in a list of perRecipients
     // If you would rather send one DSN with muliple recipients then one could write their own Job.
     //
     var notification = new DSN(perMessage, new List<DSNPerRecipient> { perRecipient });
     var sender = new MailAddress(mdn.Sender);
     var notificationMessage = new DSNMessage(sender.Address, new MailAddress("Postmaster@" + sender.Host).Address, notification);
     notificationMessage.AssignMessageID();
     notificationMessage.SubjectValue = string.Format("{0}:{1}", "Rejected", mdn.SubjectValue);
     notificationMessage.Timestamp();
     return notificationMessage;
 }
        /// <summary>
        /// Generate external notification messages for failed final destination delivery
        /// </summary>
        /// <param name="envelope"></param>
        /// <param name="recipients">sending failure status for these message recipients</param>
        /// <returns>An DSNmessage</returns>
        public DSNMessage ProduceFailure(IncomingMessage envelope, DirectAddressCollection recipients)
        {
            if (envelope == null)
            {
                throw new ArgumentNullException("envelope");
            }

            if (string.IsNullOrEmpty(m_settings.ProductName))
            {
                throw new ArgumentException("reportingAgentName:AgentSettings:ProductName");  
            }

            DSNPerMessage perMessage = new DSNPerMessage(envelope.Sender.Host, envelope.Message.IDValue);

            //
            // Un-Deliverable recipients
            //
            List<DSNPerRecipient> dsnPerRecipients = envelope.CreatePerRecipientStatus(recipients.AsMailAddresses()
                , m_settings.Text, m_settings.AlwaysAck, DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent
                , DSNStandard.DSNStatus.DELIVERY_OTHER).ToList();
            

            DSN dsn = new DSN(perMessage, dsnPerRecipients);

            //Configure and/or dynamic plus refactor
            //TODO: Split messages by domain.  See envelope.Recipients[0] below.
            return envelope.Message.CreateStatusMessage(new MailAddress("Postmaster@" + envelope.Recipients[0].Host), dsn);

        }
        /// <summary>
        /// Generate internal notification messages (if any) for this outgoing message
        /// </summary>
        /// <param name="envelope"></param>
        /// <param name="recipients">sending failure status for these message recipients</param>
        /// <returns>An DSNmessage</returns>
        public DSNMessage ProduceFailure(OutgoingMessage envelope, DirectAddressCollection recipients)
        {
            if (envelope == null)
            {
                throw new ArgumentNullException("envelope");
            }

            if (string.IsNullOrEmpty(m_settings.ProductName))
            {
                throw new ArgumentException("reportingAgentName:AgentSettings:ProductName");
            }

            DSNPerMessage perMessage = new DSNPerMessage(envelope.Sender.Host, envelope.Message.IDValue);

            //
            // Un-Secured recipients
            //
            List<DSNPerRecipient> dsnPerRecipients = envelope.CreatePerRecipientStatus(recipients.UnResolvedCertificates().AsMailAddresses()
                , m_settings.Text, m_settings.AlwaysAck, DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent
                , DSNStandard.DSNStatus.UNSECURED_STATUS).ToList();
            //
            // Un-Trusted recipients
            //
            dsnPerRecipients.AddRange(envelope.CreatePerRecipientStatus(recipients.ResolvedCertificates().AsMailAddresses()
                , m_settings.Text, m_settings.AlwaysAck, DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent
                , DSNStandard.DSNStatus.UNTRUSTED_STATUS).ToList());

            DSN dsn = new DSN(perMessage, dsnPerRecipients);

            //Configure and/or dynamic plus refactor
            return envelope.Message.CreateStatusMessage(new MailAddress("Postmaster@" + envelope.Sender.Host), dsn);

        }
Ejemplo n.º 8
0
        DSN CreateFailedStatusNotification(int recipients)
        {
            ReportingMtaName = "reporting_mta_name";
            var perMessage = new DSNPerMessage(ReportingMtaName, OriginalID);

            var perRecipients = new List<DSNPerRecipient>();
            for (int i = 1; i <= recipients; i++)
            {
                perRecipients.Add(new DSNPerRecipient(DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent
                                                      , DSNStandard.DSNStatus.UNDEFINED_STATUS,
                                                      new MailAddress(String.Format("User{0}@kryptiq.com", i))));
                
            }
            
            var dsn = new DSN(perMessage, perRecipients);

            return dsn;
        }