/// <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)); }