コード例 #1
0
 public SmtpClient(string host, int port, string email, string password, bool enableSsl)
     : this(host, port, enableSsl)
 {
     if (enableSsl)
     {
         client = new SmtpSslClient(host, port, email, password, AuthType);
     }
     else
     {
         client = new SmtpNoSslClient(host, port, email, password, AuthType);
     }
     IsAuthorized = client.IsAuthorized;
 }
コード例 #2
0
 public SmtpClient(string host, int port, bool enableSsl)
 {
     this.host = host;
     this.port = port;
     EnableSsl = enableSsl;
     if (enableSsl)
     {
         client = new SmtpSslClient(host, port);
     }
     else
     {
         client = new SmtpNoSslClient(host, port);
     }
 }
コード例 #3
0
        public bool Authorize(string email, string password)
        {
            if (host == null || port == null)
            {
                throw new ArgumentNullException();
            }

            if (IsAuthorized)
            {
                throw new SmtpException.AuthFaildException("You are still authorize");
            }

            if (EnableSsl)
            {
                client = new SmtpSslClient(host, port.Value, email, password, AuthType);
            }
            else
            {
                client = new SmtpNoSslClient(host, port.Value, email, password, AuthType);
            }
            IsAuthorized = client.IsAuthorized;
            return(IsAuthorized);
        }