Esempio n. 1
0
        public void TestFiles(string fileName)
        {
            string filePath = Path.Combine("Mail\\TestFiles", fileName);
            string mailtext = File.ReadAllText(filePath);

            Message message = null;

            Assert.DoesNotThrow(() => message = Message.Load(mailtext));

            if (SMIMEStandard.IsContentMultipartSignature(message.ParsedContentType))
            {
                SignedEntity signedEntity = null;

                Assert.DoesNotThrow(() => signedEntity = SignedEntity.Load(message));
                message.Headers = message.Headers.SelectNonMimeHeaders();
                message.UpdateBody(signedEntity.Content); // this will merge in content + content specific mime headers
            }

            Message extracted = null;

            Assert.DoesNotThrow(() => extracted = WrappedMessage.ExtractInner(message));

            Header to = null;

            Assert.DoesNotThrow(() => to = extracted.To);

            MailAddressCollection addresses = null;

            Assert.DoesNotThrow(() => addresses = MailParser.ParseAddressCollection(to));
            Assert.True(addresses.Count > 0);

            Assert.DoesNotThrow(() => MailParser.ParseMailAddress(extracted.From));
        }
Esempio n. 2
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);
        }