Пример #1
0
        /// <inheritdoc/>
        public async Task Process(IConnection connection, SmtpCommand command)
        {
            if (!string.IsNullOrEmpty(connection.Session.ClientName))
            {
                await connection.WriteResponse(
                    new SmtpResponse(
                        StandardSmtpResponseCode.BadSequenceOfCommands,
                        "You already said HELO")).ConfigureAwait(false);

                return;
            }

            connection.Session.ClientName = command.ArgumentsText ?? string.Empty;

            SmtpStringBuilder text = new SmtpStringBuilder();

            text.AppendLine("Nice to meet you.");

            foreach (Extensions.IExtensionProcessor extensionProcessor in connection.ExtensionProcessors)
            {
                foreach (string ehloKeyword in await extensionProcessor.GetEHLOKeywords().ConfigureAwait(false))
                {
                    text.AppendLine(ehloKeyword);
                }
            }

            await connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.OK, text.ToString().TrimEnd())).ConfigureAwait(false);
        }
Пример #2
0
        /// <summary>
        /// Returns a <see cref="string"/> that represents the response.
        /// </summary>
        /// <returns>A <see cref="string"/> that represents the response.</returns>
        public override string ToString()
        {
            SmtpStringBuilder result = new SmtpStringBuilder();

            string[] lines = this.Message.Split(new string[] { "\r\n" }, System.StringSplitOptions.None);

            for (int l = 0; l < lines.Length; l++)
            {
                string line = lines[l];

                if (l == lines.Length - 1)
                {
                    result.AppendLine(this.Code + " " + line);
                }
                else
                {
                    result.AppendLine(this.Code + "-" + line);
                }
            }

            return(result.ToString());
        }