public static SmtpServerCapability ParseCapability(SmtpResponseReader reader)
        {
            var capability = new SmtpServerCapability();
            while (true) {
                if (!reader.IsKnownCapability) {
                    if (reader.IsLast) {
                        break;
                    }
                    reader.ReadNextLine();
                    continue;
                }

                if (reader.Text.StartsWith("AUTH")) {
                    var sub = reader.Text.Substring(5);
                    var split = sub.Split(' ');
                    foreach (var auth in split.Select(item => string.Format("AUTH={0}", item))) {
                        if (!capability.Items.Contains(auth)) {
                            capability.Store(auth);
                        }
                    }
                } else {
                    if (!capability.Items.Contains(reader.Text)) {
                        capability.Store(reader.Text);
                    }
                }

                if (reader.IsLast) {
                    break;
                }

                reader.ReadNextLine();
            }
            return capability;
        }
Beispiel #2
0
        internal SmtpResponseReader Receive(TimeSpan timeout)
        {
            var reader = new SmtpResponseReader(this, timeout);

            reader.ReadNextLine();
            return(reader);
        }
Beispiel #3
0
        private SmtpResponseReader SendSenders(Message message)
        {
            SmtpResponseReader reader = null;

            foreach (var from in message.From)
            {
                var text    = string.Format("MAIL FROM:<{0}>", from.Address.FullAddress);
                var command = new SmtpCommand(text);
                reader = SendAndReceive(command);

                if (reader.IsFatalOrErroneous)
                {
                    return(reader);
                }
            }
            return(reader);
        }
        public static SmtpServerCapability ParseCapability(SmtpResponseReader reader)
        {
            var capability = new SmtpServerCapability();

            while (true)
            {
                if (!reader.IsKnownCapability)
                {
                    if (reader.IsLast)
                    {
                        break;
                    }
                    reader.ReadNextLine();
                    continue;
                }

                if (reader.Text.StartsWith("AUTH"))
                {
                    var sub   = reader.Text.Substring(5);
                    var split = sub.Split(' ');
                    foreach (var auth in split.Select(item => string.Format("AUTH={0}", item)))
                    {
                        if (!capability.Items.Contains(auth))
                        {
                            capability.Store(auth);
                        }
                    }
                }
                else
                {
                    if (!capability.Items.Contains(reader.Text))
                    {
                        capability.Store(reader.Text);
                    }
                }

                if (reader.IsLast)
                {
                    break;
                }

                reader.ReadNextLine();
            }
            return(capability);
        }
Beispiel #5
0
        private SmtpResponseReader SendRecipients(Message message)
        {
            SmtpResponseReader reader = null;
            var recipients            = new List <EmailContact>();

            recipients.AddRange(message.Ccs);
            recipients.AddRange(message.Bccs);
            recipients.AddRange(message.To);
            recipients.RemoveDuplicates();

            foreach (var recipient in recipients)
            {
                var text    = string.Format("RCPT TO:<{0}>", recipient.Address.FullAddress);
                var command = new SmtpCommand(text);
                reader = SendAndReceive(command);

                if (reader.IsFatalOrErroneous)
                {
                    return(reader);
                }
            }

            return(reader);
        }
Beispiel #6
0
 internal SmtpResponseReader Receive(TimeSpan timeout)
 {
     var reader = new SmtpResponseReader(this, timeout);
     reader.ReadNextLine();
     return reader;
 }