Beispiel #1
0
        public void Evaluate(int SpreadMax)
        {
            double dblrefresh;

            this.FPinInRefresh.GetValue(0, out dblrefresh);

            if (dblrefresh >= 0.5)
            {
                string host, username, pwd;
                double dblport, dblcount;
                this.FPinInHost.GetString(0, out host);
                this.FPinInPort.GetValue(0, out dblport);
                this.FPinInUsername.GetString(0, out username);
                this.FPinInPassword.GetString(0, out pwd);
                this.FPinInCount.GetValue(0, out dblcount);

                Higuchi.Net.Pop3.Pop3Client client = new Higuchi.Net.Pop3.Pop3Client();
                client.ServerName = host;
                client.Port       = Convert.ToInt32(dblport);
                client.UserName   = username;
                client.Password   = pwd;
                if (client.Authenticate())
                {
                    long Count = client.GetTotalMessageCount();



                    int max = Math.Min(Convert.ToInt32(dblcount), Convert.ToInt32(Count));

                    this.FPinOutSubject.SliceCount = max;
                    this.FPinOutBody.SliceCount    = max;
                    this.FPinOutFrom.SliceCount    = max;

                    long idx = Count;
                    for (int i = 0; i < max; i++)
                    {
                        Higuchi.Net.Pop3.Pop3Message msg = client.GetMessage(idx);
                        this.FPinOutFrom.SetString(i, msg.From);
                        this.FPinOutSubject.SetString(i, msg.Subject);
                        this.FPinOutBody.SetString(i, msg.BodyText);
                        idx--;
                    }
                }
                else
                {
                    this.FHost.Log(TLogType.Error, "Authentication failed");
                    this.FPinOutBody.SliceCount    = 0;
                    this.FPinOutSubject.SliceCount = 0;
                    this.FPinOutFrom.SliceCount    = 0;
                }
            }
        }
Beispiel #2
0
        void updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            _updateTimer.Stop();

            lock (_emailLock)
            {
                _client                = new Higuchi.Net.Pop3.Pop3Client();
                _client.UserName       = ClientUserName;
                _client.Password       = ClientPassword;
                _client.ServerName     = PopServer;
                _client.Port           = PopPort;
                _client.Ssl            = true;
                _client.ReceiveTimeout = 30000;
                _client.Authenticate();
                long mailCount = _client.GetTotalMessageCount();
                if (mailCount > _previousMailCount)
                {
                    for (long i = _previousMailCount + 1; i <= mailCount; i++)
                    {
                        Higuchi.Net.Pop3.Pop3Message message = _client.GetMessage(i);
                        if (message.To == ClientEmailAddress && message.From == ServerEmailAddress && message.Subject == "TunnelProxy")
                        {
                            List <Higuchi.Net.Pop3.Pop3Content> l = Higuchi.Net.Pop3.Pop3Message.GetAttachedContents(message);
                            MemoryStream dataStream = new MemoryStream(10000);

                            l[0].DecodeData(dataStream, false);
                            dataStream.Flush();

                            byte[] data = dataStream.ToArray();

                            //byte[] data = ConversionUtils.ConvertToBytes(l[0].BodyText);

                            //string body = message.BodyText;

                            //if (body.EndsWith("\r\n\r\n"))
                            //	body = body.Substring(0, body.Length - 4);
                            //byte[] data = ConversionUtils.ConvertToBytes(body);
                            if (DataReceived != null)
                            {
                                DataReceived(this, new DataReceivedEventArgs(data));
                            }
                        }
                    }
                    _previousMailCount = mailCount;
                }
            }
            _updateTimer.Start();
        }
Beispiel #3
0
        public EmailTunnel(string smtpServer, int smtpPort, string imapServer,
                           int imapPort, string serverEmailAddress, string clientEmailAdress,
                           string clientUserName, string clientPassword)
        {
            SmtpServer         = smtpServer;
            SmtpPort           = smtpPort;
            PopServer          = imapServer;
            PopPort            = imapPort;
            ServerEmailAddress = serverEmailAddress;
            ClientEmailAddress = clientEmailAdress;
            ClientUserName     = clientUserName;
            ClientPassword     = clientPassword;

            //Koolwired.Imap.ImapConnect connection = new Koolwired.Imap.ImapConnect(ImapServer, ImapPort, true);
            //connection.LoginType = Koolwired.Imap.LoginType.LOGIN;
            //Koolwired.Imap.ImapCommand _command = new Koolwired.Imap.ImapCommand(connection);
            //Koolwired.Imap.ImapAuthenticate authenticate = new Koolwired.Imap.ImapAuthenticate(connection, ClientUserName, ClientPassword);
            //connection.Open();
            //authenticate.Login();

            //InterIMAP.IMAPConfig config = new InterIMAP.IMAPConfig(imapServer, ClientUserName, ClientPassword,
            //    true, true, "INBOX");
            //_imapClient = new InterIMAP.IMAPClient();
            //_imapClient.Config = config;
            //_imapClient.Logon();

            //Pop3.Pop3Client popclient = new Pop3.Pop3Client();
            //popclient.Connect(, ClientUserName, ClientPassword);
            _client                = new Higuchi.Net.Pop3.Pop3Client();
            _client.UserName       = ClientUserName;
            _client.Password       = ClientPassword;
            _client.ServerName     = PopServer;
            _client.Port           = PopPort;
            _client.Ssl            = true;
            _client.ReceiveTimeout = 30000;
            _client.Authenticate();
            _previousMailCount    = _client.GetTotalMessageCount();
            _updateTimer          = new System.Timers.Timer(100);
            _updateTimer.Elapsed += updateTimer_Elapsed;
            _updateTimer.Start();
        }