示例#1
0
		// make the actual connection
		// and HELO handshaking
		void Connect ()
		{
			tcpConnection = new TcpClient (server, port);
	    
			NetworkStream stream = tcpConnection.GetStream ();
			smtp = new SmtpStream (stream);
		}
        void ChangeToSSLSocket()
        {
#if TARGET_JVM
            java.lang.Class          c = vmw.common.TypeUtils.ToClass(smtp.Stream);
            java.lang.reflect.Method m = c.getMethod("ChangeToSSLSocket", null);
            m.invoke(smtp.Stream, new object[] {});
#else
            // Load Mono.Security.dll
            Assembly a;
            try
            {
                a = Assembly.Load(Consts.AssemblyMono_Security);
            }
            catch (System.IO.FileNotFoundException)
            {
                throw new SmtpException("Cannot load Mono.Security.dll");
            }
            Type     tSslClientStream = a.GetType("Mono.Security.Protocol.Tls.SslClientStream");
            object[] consArgs         = new object[4];
            consArgs[0] = smtp.Stream;
            consArgs[1] = server;
            consArgs[2] = true;
            Type tSecurityProtocolType = a.GetType("Mono.Security.Protocol.Tls.SecurityProtocolType");
            int  nSsl3Val = (int)Enum.Parse(tSecurityProtocolType, "Ssl3");
            int  nTlsVal  = (int)Enum.Parse(tSecurityProtocolType, "Tls");
            consArgs[3] = Enum.ToObject(tSecurityProtocolType, nSsl3Val | nTlsVal);

            object objSslClientStream = Activator.CreateInstance(tSslClientStream, consArgs);

            if (objSslClientStream != null)
            {
                smtp = new SmtpStream((Stream)objSslClientStream);
            }
#endif
        }
示例#3
0
        void ChangeToSSLSocket()
        {
            var sslStream = new SslStream(smtp.Stream);

            sslStream.AuthenticateAsClient(server);
            smtp = new SmtpStream(sslStream);
        }
示例#4
0
        void ChangeToSSLSocket()
        {
            // Load Mono.Security.dll
            Assembly a;

            try {
                a = Assembly.Load(Consts.AssemblyMono_Security);
            } catch (System.IO.FileNotFoundException) {
                throw new SmtpException("Cannot load Mono.Security.dll");
            }
            Type tSslClientStream = a.GetType("Mono.Security.Protocol.Tls.SslClientStream");

            object[] consArgs = new object[4];
            consArgs[0] = smtp.Stream;
            consArgs[1] = server;
            consArgs[2] = true;
            Type tSecurityProtocolType = a.GetType("Mono.Security.Protocol.Tls.SecurityProtocolType");
            int  nSsl3Val = (int)Enum.Parse(tSecurityProtocolType, "Ssl3");
            int  nTlsVal  = (int)Enum.Parse(tSecurityProtocolType, "Tls");

            consArgs[3] = Enum.ToObject(tSecurityProtocolType, nSsl3Val | nTlsVal);

            object objSslClientStream = Activator.CreateInstance(tSslClientStream, consArgs);

            if (objSslClientStream != null)
            {
                smtp = new SmtpStream((Stream)objSslClientStream);
            }
        }
        // make the actual connection
        // and HELO handshaking
        void Connect()
        {
            tcpConnection = new TcpClient(server, port);

            NetworkStream stream = tcpConnection.GetStream();

            smtp = new SmtpStream(stream);
        }
	// make the actual connection
	// and HELO handshaking
	private void Connect() {
	    tcpConnection = new TcpClient( server , 25 );
	    
	    Stream stream = tcpConnection.GetStream();
	    smtp = new SmtpStream( stream );
	    
	    // read the server greeting
	    smtp.ReadResponse();
	    smtp.CheckForStatusCode( 220 );
	   
	    // write the HELO command to the server
	    smtp.WriteHelo( Dns.GetHostName() );
	    	    
	}
示例#7
0
		void ChangeToSSLSocket ()
		{
			// Load Mono.Security.dll
			Assembly a;
			try {
				a = Assembly.Load (Consts.AssemblyMono_Security);
			} catch (System.IO.FileNotFoundException) {
				throw new SmtpException ("Cannot load Mono.Security.dll");
			}
			Type tSslClientStream = a.GetType ("Mono.Security.Protocol.Tls.SslClientStream");
			object[] consArgs = new object[4];
			consArgs[0] = smtp.Stream;
			consArgs[1] = server;
			consArgs[2] = true;
			Type tSecurityProtocolType = a.GetType ("Mono.Security.Protocol.Tls.SecurityProtocolType");
			int nSsl3Val = (int) Enum.Parse (tSecurityProtocolType, "Ssl3");
			int nTlsVal = (int) Enum.Parse (tSecurityProtocolType, "Tls");
			consArgs[3] = Enum.ToObject (tSecurityProtocolType, nSsl3Val | nTlsVal);

			object objSslClientStream = Activator.CreateInstance (tSslClientStream, consArgs); 

			if (objSslClientStream != null)
				smtp = new SmtpStream ((Stream)objSslClientStream);
		}
示例#8
0
		void ChangeToSSLSocket ()
		{
#if TARGET_JVM
			java.lang.Class c = vmw.common.TypeUtils.ToClass (smtp.Stream);
			java.lang.reflect.Method m = c.getMethod ("ChangeToSSLSocket", null);
			m.invoke (smtp.Stream, new object[]{});
#else
			// Load Mono.Security.dll
			Assembly a;
			try {
				a = Assembly.Load (Consts.AssemblyMono_Security);
			} catch (System.IO.FileNotFoundException) {
				throw new SmtpException ("Cannot load Mono.Security.dll");
			}
			Type tSslClientStream = a.GetType ("Mono.Security.Protocol.Tls.SslClientStream");
			object[] consArgs = new object[4];
			consArgs[0] = smtp.Stream;
			consArgs[1] = server;
			consArgs[2] = true;
			Type tSecurityProtocolType = a.GetType ("Mono.Security.Protocol.Tls.SecurityProtocolType");
			int nSsl3Val = (int) Enum.Parse (tSecurityProtocolType, "Ssl3");
			int nTlsVal = (int) Enum.Parse (tSecurityProtocolType, "Tls");
			consArgs[3] = Enum.ToObject (tSecurityProtocolType, nSsl3Val | nTlsVal);

			object objSslClientStream = Activator.CreateInstance (tSslClientStream, consArgs); 

			if (objSslClientStream != null)
				smtp = new SmtpStream ((Stream)objSslClientStream);
#endif
		}