Beispiel #1
0
        /// <inheritdoc/>
        public async Task Process(IConnection connection, SmtpCommand command)
        {
            if (connection.CurrentMessage != null)
            {
                await connection.WriteResponse(new SmtpResponse(
                                                   StandardSmtpResponseCode.BadSequenceOfCommands,
                                                   "You already told me who the message was from")).ConfigureAwait(false);

                return;
            }

            if (command.ArgumentsText.Length == 0)
            {
                await connection.WriteResponse(
                    new SmtpResponse(
                        StandardSmtpResponseCode.SyntaxErrorInCommandArguments,
                        "Must specify from address or <>")).ConfigureAwait(false);

                return;
            }

            ArgumentsParser argumentsParser = new ArgumentsParser(command.ArgumentsText);

            System.Collections.Generic.IReadOnlyCollection <string> arguments = argumentsParser.Arguments;

            string from = arguments.First();

            if (from.StartsWith("<", StringComparison.OrdinalIgnoreCase))
            {
                from = from.Remove(0, 1);
            }

            if (from.EndsWith(">", StringComparison.OrdinalIgnoreCase))
            {
                from = from.Remove(from.Length - 1, 1);
            }

            await connection.Server.Behaviour.OnMessageStart(connection, from).ConfigureAwait(false);

            await connection.NewMessage().ConfigureAwait(false);

            connection.CurrentMessage.ReceivedDate = this.currentDateTimeProvider.GetCurrentDateTime();
            connection.CurrentMessage.From         = from;

            try
            {
                await this.ParameterProcessorMap.Process(connection, arguments.Skip(1).ToArray(), true).ConfigureAwait(false);

                await connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.OK, "New message started")).ConfigureAwait(false);
            }
            catch
            {
                await connection.AbortMessage().ConfigureAwait(false);

                throw;
            }
        }
Beispiel #2
0
        public async Task ProcessAsync(IConnection connection, SmtpCommand command)
        {
            if (connection.CurrentMessage != null)
            {
                await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.BadSequenceOfCommands,
                                                                     "You already told me who the message was from"));

                return;
            }

            if (command.ArgumentsText.Length == 0)
            {
                await connection.WriteResponseAsync(
                    new SmtpResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments,
                                     "Must specify from address or <>"));

                return;
            }

            ArgumentsParser argumentsParser = new ArgumentsParser(command.ArgumentsText);

            string[] arguments = argumentsParser.Arguments;

            string from = arguments.First();

            if (from.StartsWith("<"))
            {
                from = from.Remove(0, 1);
            }

            if (from.EndsWith(">"))
            {
                from = from.Remove(from.Length - 1, 1);
            }

            connection.Server.Behaviour.OnMessageStart(connection, from);
            connection.NewMessage();
            connection.CurrentMessage.ReceivedDate = _currentDateTimeProvider.GetCurrentDateTime();
            connection.CurrentMessage.From         = from;

            try
            {
                await ParameterProcessorMap.ProcessAsync(connection, arguments.Skip(1).ToArray(), true);

                await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.OK, "New message started"));
            }
            catch
            {
                connection.AbortMessage();
                throw;
            }
        }
Beispiel #3
0
        public void Process(IConnection connection, SmtpCommand command)
        {
            if (connection.CurrentMessage != null)
            {
                connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.BadSequenceOfCommands,
                                                          "You already told me who the message was from"));
                return;
            }

            if (command.ArgumentsText.Length == 0)
            {
                connection.WriteResponse(
                    new SmtpResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments,
                                     "Must specify from address or <>"));
                return;
            }

            string from = command.Arguments.First();

            if (from.StartsWith("<"))
            {
                from = from.Remove(0, 1);
            }

            if (from.EndsWith(">"))
            {
                from = from.Remove(from.Length - 1, 1);
            }

            connection.Server.Behaviour.OnMessageStart(connection, from);
            connection.NewMessage();
            connection.CurrentMessage.From = from;


            try
            {
                ParameterProcessorMap.Process(command.Arguments.Skip(1).ToArray(), true);
                connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.OK, "Okey dokey"));
            }
            catch
            {
                connection.AbortMessage();
                throw;
            }
        }
Beispiel #4
0
        public async Task ProcessAsync(IConnection connection, SmtpCommand command)
        {
            if (connection.CurrentMessage != null)
            {
                await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.BadSequenceOfCommands,
                                                                   "You already told me who the message was from"));
                return;
            }

            if (command.ArgumentsText.Length == 0)
            {
                await connection.WriteResponseAsync(
                    new SmtpResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments,
                                     "Must specify from address or <>"));
                return;
            }

            ArgumentsParser argumentsParser = new ArgumentsParser(command.ArgumentsText);
            string[] arguments = argumentsParser.Arguments;

            string from = arguments.First();
            if (from.StartsWith("<"))
                from = from.Remove(0, 1);

            if (from.EndsWith(">"))
                from = from.Remove(from.Length - 1, 1);

            connection.Server.Behaviour.OnMessageStart(connection, from);
            connection.NewMessage();
            connection.CurrentMessage.ReceivedDate = _currentDateTimeProvider.GetCurrentDateTime();
            connection.CurrentMessage.From = from;

            try
            {
                await ParameterProcessorMap.ProcessAsync(connection, arguments.Skip(1).ToArray(), true);
                await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.OK, "New message started"));
            }
            catch
            {
                connection.AbortMessage();
                throw;
            }
        }
Beispiel #5
0
        public void Process(IConnection connection, SmtpCommand command)
        {
            if (connection.CurrentMessage != null)
            {
                connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.BadSequenceOfCommands,
                                                                   "You already told me who the message was from"));
                return;
            }

            if (command.ArgumentsText.Length == 0)
            {
                connection.WriteResponse(
                    new SmtpResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments,
                                     "Must specify from address or <>"));
                return;
            }

            string from = command.Arguments.First();
            if (from.StartsWith("<"))
                from = from.Remove(0, 1);

            if (from.EndsWith(">"))
                from = from.Remove(from.Length - 1, 1);

            connection.Server.Behaviour.OnMessageStart(connection, from);
            connection.NewMessage();
            connection.CurrentMessage.From = from;


            try
            {
                ParameterProcessorMap.Process(command.Arguments.Skip(1).ToArray(), true);
                connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.OK, "Okey dokey"));
            }
            catch
            {
                connection.AbortMessage();
                throw;
            }
        }
Beispiel #6
0
        /// <inheritdoc/>
        public async Task Process(IConnection connection, SmtpCommand command)
        {
            await connection.AbortMessage().ConfigureAwait(false);

            await connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.OK, "Rset completed")).ConfigureAwait(false);
        }
Beispiel #7
0
 public void Process(IConnection connection, SmtpCommand command)
 {
     connection.AbortMessage();
     connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.OK, "Rset completed"));
 }
Beispiel #8
0
 public async Task ProcessAsync(IConnection connection, SmtpCommand command)
 {
     connection.AbortMessage();
     await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.Ok, "Rset completed"));
 }
Beispiel #9
0
 public async Task ProcessAsync(IConnection connection, SmtpCommand command)
 {
     connection.AbortMessage();
     await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.OK, "Rset completed"));
 }