Click here to Skip to main content
15,897,704 members
Articles / Web Development / HTML

My own Mailinator in 5 minutes

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
19 Nov 2012CPOL6 min read 31.7K   405   13  
A simple Mailinator clone developed in five minutes with the NetFluid framework
using System;
using System.Collections.Generic;
using System.Text;

namespace LumiSoft.Net.SMTP.Client
{
    /// <summary>
    /// SMTP client exception.
    /// </summary>
    public class SMTP_ClientException : Exception
    {
        private SMTP_t_ReplyLine[] m_pReplyLines  = null;

        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="responseLine">SMTP server response line.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>responseLine</b> is null.</exception>
        public SMTP_ClientException(string responseLine) : base(responseLine.TrimEnd())
        {
            if(responseLine == null){
                throw new ArgumentNullException("responseLine");
            }

            m_pReplyLines = new SMTP_t_ReplyLine[]{SMTP_t_ReplyLine.Parse(responseLine)};
        }

        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="replyLines">SMTP server error reply lines.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>replyLines</b> is null reference.</exception>
        public SMTP_ClientException(SMTP_t_ReplyLine[] replyLines) : base(replyLines[0].ToString().TrimEnd())
        {
            if(replyLines == null){
                throw new ArgumentNullException("replyLines");
            }

            m_pReplyLines = replyLines;            
        }


        #region Properties Implementation

        /// <summary>
        /// Gets SMTP status code.
        /// </summary>
        [Obsolete("Use property 'ReplyLines' insead.")]
        public int StatusCode
        {
            get{ return m_pReplyLines[0].ReplyCode; }
        }

        /// <summary>
        /// Gets SMTP server response text after status code.
        /// </summary>
        [Obsolete("Use property 'ReplyLines' insead.")]
        public string ResponseText
        {
            get{ return m_pReplyLines[0].Text; }
        }

        /// <summary>
        /// Gets SMTP server error reply lines.
        /// </summary>
        public SMTP_t_ReplyLine[] ReplyLines
        {
            get{ return m_pReplyLines; }
        }

        /// <summary>
        /// Gets if it is permanent SMTP(5xx) error.
        /// </summary>
        public bool IsPermanentError
        {
            get{
                if(m_pReplyLines[0].ReplyCode >= 500 && m_pReplyLines[0].ReplyCode <= 599){
                    return true;
                }
                else{
                    return false;
                }
            }
        }

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Genny Mobility
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions