コード例 #1
0
        public void TestUntrusted()
        {
            //
            // This should be accepted because the envelope is what we look at
            //
            MessageEnvelope envelope = new MessageEnvelope(BadMessage,
                                                           DirectAddressCollection.ParseSmtpServerEnvelope("*****@*****.**"),
                                                           new DirectAddress("*****@*****.**")
                                                           );

            Assert.DoesNotThrow(() => m_agent.SecurityAgent.ProcessOutgoing(envelope));

            envelope = new MessageEnvelope(string.Format(TestMessage, Guid.NewGuid()),
                                           DirectAddressCollection.ParseSmtpServerEnvelope("*****@*****.**"),
                                           new DirectAddress("*****@*****.**"));

            //
            // This SHOULD throw an exception
            //
            Assert.Throws <OutgoingAgentException>(() => m_agent.SecurityAgent.ProcessOutgoing(envelope));
        }
コード例 #2
0
ファイル: CDOSmtpMessage.cs プロジェクト: blinds52/nhind
        //
        // A CDO Message could be arriving via the SMTP server, or could have been constructed manually
        // The one created by SMTP has envelope information
        // Returns false if no envelope info is available. We have to look within message headers in that case
        //
        bool ExtractEnvelopeFields(CDO.Message message, ref DirectAddressCollection recipientAddresses, ref DirectAddress senderAddress)
        {
            if (!this.HasEnvelope)
            {
                //
                // No envelope
                //
                return(false);
            }

            recipientAddresses = null;
            senderAddress      = null;

            string sender = message.GetEnvelopeSender();

            if (string.IsNullOrEmpty(sender))
            {
                throw new SmtpAgentException(SmtpAgentError.NoSenderInEnvelope);
            }
            //
            // In SMTP Server, the MAIL TO (sender) in the envelope can be empty if the message is from the server postmaster
            // The actual postmaster address is found in the message itself
            //
            if (Health.Direct.SmtpAgent.Extensions.IsSenderLocalPostmaster(sender))
            {
                return(false);
            }
            string recipients = message.GetEnvelopeRecipients();

            if (string.IsNullOrEmpty(recipients))
            {
                throw new SmtpAgentException(SmtpAgentError.NoRecipientsInEnvelope);
            }

            recipientAddresses = DirectAddressCollection.ParseSmtpServerEnvelope(recipients);
            senderAddress      = new DirectAddress(sender);

            return(true);
        }