Example #1
0
        public override async Task ExecuteAsync(SmtpSession context, CancellationToken cancellationToken)
        {
            context.Reset();
            int messageSize = GetMessageSize();

            if (_maxMessageSize > 0 && messageSize > _maxMessageSize)
            {
                await context.Stream.ReplyAsync(SmtpResponse.SizeLimitExceeded, cancellationToken);

                return;
            }

            switch (_filter(Address))
            {
            case ValidationResult.Yes:
                context.From = Address;
                await context.Stream.ReplyAsync(SmtpResponse.Ok, cancellationToken);

                break;

            case ValidationResult.NoTemporarily:
                await context.Stream.ReplyAsync(SmtpResponse.MailboxUnavailable, cancellationToken);

                break;

            case ValidationResult.NoPermanently:
                await context.Stream.ReplyAsync(SmtpResponse.MailboxNameNotAllowed, cancellationToken);

                break;

            default:
                throw new NotSupportedException("The Acceptance state is not supported.");
            }
        }
Example #2
0
 public override Task ExecuteAsync(SmtpSession context, CancellationToken cancellationToken)
 {
     context.Reset();
     return(context.Stream.ReplyAsync(SmtpResponse.Ok, cancellationToken));
 }