Beispiel #1
0
        public MessageEnvelope ProcessIncoming(ISmtpMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            return(this.ProcessIncoming(message, message.GetEnvelope()));
        }
Beispiel #2
0
        public void ProcessMessage(ISmtpMessage message)
        {
            bool?           isIncoming = null;
            MessageEnvelope envelope   = null;

            try
            {
                this.VerifyInitialized();
                //
                // Preprocessing may involve housekeeping like logging message arrival
                //
                this.PreProcessMessage(message);
                //
                // Let the agent do its thing
                //
                envelope = message.GetEnvelope();
                envelope = this.ProcessEnvelope(message, envelope);
                if (envelope == null)
                {
                    throw new SmtpAgentException(SmtpAgentError.InvalidEnvelopeFromAgent);
                }
                isIncoming = envelope is IncomingMessage;
                //
                // Capture envelope sender/receiver in the message
                //
                this.UpdateXHeaders(envelope);
                //
                // Replace the contents of the original message with what the agent gave us
                //
                this.UpdateMessageText(message, envelope);
                //
                // We did well...
                //
                this.AcceptMessage(message, isIncoming.Value);
                //
                // We may want want to update logs and do some final post processing
                //
                this.PostProcessMessage(message, envelope);
            }
            catch (FaultException <ConfigStoreFault> ex)
            {
                //
                // Absorb Mdn type errors
                //
                if (IsMdnFault(ex))
                {
                    Logger.Info("Ignored MDN: {0}", ex.ToString());
                }
                else
                {
                    this.RejectMessage(message, isIncoming);
                    Logger.Error("While processing message {0}", ex.ToString());
                    throw;
                }
            }
            catch (Exception ex)
            {
                HandleMessageRejection(message, envelope, isIncoming, ex);

                throw;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Convert <see cref="ISmtpMessage"/> into a audit string.
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public string Build(ISmtpMessage message)
 {
     return(message.GetEnvelope().Message.Headers.ToString());
 }
Beispiel #4
0
 public MessageEnvelope ProcessIncoming(ISmtpMessage message)
 {
     if (message == null)
     {
         throw new ArgumentNullException("message");
     }
     
     return this.ProcessIncoming(message, message.GetEnvelope());
 }
Beispiel #5
0
        public void ProcessMessage(ISmtpMessage message)
        {
            bool? isIncoming = null;
            MessageEnvelope envelope = null;
            try
            {
                this.VerifyInitialized();
                //
                // Preprocessing may involve housekeeping like logging message arrival
                //
                this.PreProcessMessage(message);
                //
                // Let the agent do its thing
                //   
                envelope = message.GetEnvelope();
                envelope = this.ProcessEnvelope(message, envelope);
                if (envelope == null)
                {
                    throw new SmtpAgentException(SmtpAgentError.InvalidEnvelopeFromAgent);
                }
                isIncoming = envelope is IncomingMessage;
                //
                // Capture envelope sender/receiver in the message
                //
                this.UpdateXHeaders(envelope);
                //
                // Replace the contents of the original message with what the agent gave us
                //
                this.UpdateMessageText(message, envelope);
                //
                // We did well...
                //
                this.AcceptMessage(message, isIncoming.Value);
                //
                // We may want want to update logs and do some final post processing
                //
                this.PostProcessMessage(message, envelope);
            }
            catch (FaultException<ConfigStoreFault> ex)
            {
                //
                // Absorb Mdn type errors
                //
                if(IsMdnFault(ex))
                {
                    Logger.Info("Ignored MDN: {0}", ex.ToString());
                }
                else
                {
                    this.RejectMessage(message, isIncoming);
                    Logger.Error("While processing message {0}", ex.ToString());
                    throw;
                }
            }
            catch (Exception ex)
            {
                HandleMessageRejection(message, envelope, isIncoming, ex);

                throw;
            }
        }
Beispiel #6
0
        public string Build(ISmtpMessage message)
        {
            MessageEnvelope envelope = message.GetEnvelope();

            return(string.Format("MAILFROM={0};RCPTTO={1}", envelope.Message.FromValue, envelope.Message.ToValue));
        }