473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem with pop3

hi guys i got this code in c#.net to retrieve mails using pop3 protocal, i'm using MERCURY MAIL SERVER ........
I create a user acccount in mercury by name honey@localhost
the problem is after connecting to the server i get error saying that the password does not match( but the password is correct)

Expand|Select|Wrap|Line Numbers
  1. namespace pop
  2. {
  3.     class Program
  4.     {
  5.         public class pop
  6.         {
  7.              string server = "localhost";
  8.             string user = "honey@localhost";   // dats the user   account in mercury
  9.             string pass = "honey";
  10.             int port = 110;
  11.  
  12.             Socket s = null;
  13.  
  14.            private Socket GetClientSocket()
  15.             {
  16.  
  17.  
  18.                 Socket tempSoc = null;
  19.  
  20.                 try
  21.                 {
  22.  
  23.                     IPHostEntry hostEntry = null;
  24.                     hostEntry = Dns.Resolve(server);
  25.  
  26.  
  27.                     foreach (IPAddress add in hostEntry.AddressList)
  28.                     {
  29.                         IPEndPoint ipe = new IPEndPoint(add, port);
  30.                         tempSoc = new Socket(ipe.AddressFamily,
  31.                            SocketType.Stream, ProtocolType.Tcp);
  32.  
  33.                         tempSoc.Connect(ipe);
  34.  
  35.                         if (tempSoc.Connected)
  36.                         {
  37.                             System.Console.WriteLine("sucsesfull");
  38.                             s = tempSoc;
  39.                             break;
  40.  
  41.                         }
  42.  
  43.                         else
  44.                         {
  45.                             System.Console.WriteLine("not sucsesfull");
  46.                             continue;
  47.                         }
  48.                     }//foreach
  49.                 }
  50.                 catch (Exception e)
  51.                 {
  52.                     System.Console.WriteLine(e.ToString());
  53.                 }
  54.  
  55.             return s;
  56.  
  57.         }//GetClientSocket
  58.  
  59.             private string GetString()
  60.             {           
  61.                 byte[] buffer = new byte[256];
  62.  
  63.                 string line = null;
  64.  
  65.                 try
  66.                 {
  67.                     int byteCount = s.Receive(buffer, buffer.Length, 0);
  68.                     line = Encoding.ASCII.GetString(buffer, 0, byteCount);
  69.                     System.Console.WriteLine("Line" + line);
  70.  
  71.                 }//try
  72.  
  73.                 catch (Exception e) { System.Console.WriteLine("error in GetString()"); }
  74.  
  75.                 return line;
  76.             }//GetString
  77.  
  78.  
  79.             private void send(string user)
  80.             {
  81.                 try
  82.                 {
  83.                     byte[] bytedata = Encoding.ASCII.GetBytes(user + "\r\n");
  84.                     s.Send(bytedata);
  85.                 }//try
  86.  
  87.                 catch (Exception e)
  88.                 {
  89.                     System.Console.WriteLine("Error while sending the username");
  90.                 }
  91.  
  92.             }//send
  93.  
  94.             private void LoginToInbox()
  95.             {
  96.                 System.Console.WriteLine("In LOginToInbox");
  97.                 string returned;
  98.  
  99.                 send("user " + user);
  100.                 returned = GetString();
  101.                 System.Console.WriteLine("user   " + returned);
  102.  
  103.                 if (!returned.Substring(0, 3).Equals("+OK"))
  104.                     System.Console.WriteLine("login not excepted");
  105.  
  106.                 send("pass " + pass);
  107.                 returned = GetString();
  108.                 System.Console.WriteLine("password  " + returned);
  109.  
  110.                 if (!returned.Substring(0, 3).Equals("+OK"))
  111.                     System.Console.WriteLine("login/password not excepted");
  112.  
  113.             }//LoginToInbox
  114.  
  115.             public void OpenInbox()
  116.             {
  117.                 // get a socket ...
  118.                 s = GetClientSocket();
  119.  
  120.                 // get initial header from POP3 server ...
  121.                 string header = GetString();
  122.  
  123.                 System.Console.WriteLine("header" + header);
  124.                 try
  125.                 {
  126.  
  127.                     if (!header.Substring(0, 3).Equals("+OK"))
  128.                     {
  129.                         System.Console.WriteLine("Invalid initial POP3 response");
  130.                     }
  131.  
  132.                     // send login details ...
  133.                     LoginToInbox();
  134.  
  135.                     System.Console.WriteLine("done");
  136.                 }
  137.                 catch (Exception e) { }
  138.             }     
  139.         }//pop3
  140.  
  141.         public static void Main(string[] args)
  142.         {
  143.             pop popC = new pop();
  144.             popC.OpenInbox();
  145.  
  146.             System.Console.Read();
  147.         }
  148.     }
  149. }
Apr 10 '08 #1
0 919

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
1
by: Lev Altshuler | last post by:
Hi, I am trying to count email messages in the mailbox and read their headers. In case that there are some messages on the POP3 server and they haven't yet got to the Inbox, I get a number of...
4
by: Ron Vecchi | last post by:
I a runnning w2k3 pop3 mail server that came with iis6. I would like to write an application that progammtically creates the new mailboxes in an already established mail domain. Does anyone know...
2
by: Rui | last post by:
I need to write a proxy between pop3 client and pop3+ssl server. This proxy will receive pop3 commands from the client and will translate those commands for a pop3+ssl server, then it will receive...
0
by: Hardy Wang | last post by:
Hi, I developed an application to read email from POP3 server. Some of the codes are below: ------------------------------------------------------------------------------- Server = new...
2
by: Shimon Sim | last post by:
Is there a way to get e-mails with attachments using .NET 2.0? If not does anybody knows a component that can do this? Thank you, Shimon.
4
by: =?Utf-8?B?QWxwYW5h?= | last post by:
I am making a thin email client and want to get emails from a pop3 server...Is there any built in support in C# to get emails from a pop3 server and parse the email to show up on the UI ?
11
by: mp- | last post by:
I want to be able to allow people to check their email from my PHP online application. Given only the users 1) email address, 2) username (if applicable) and 3) password - how can I auto detect...
5
by: Craig Buchanan | last post by:
I would like to monitor a POP3 mailbox with multiple clients. However, I want to ensure that each message is processed by only one client. In essence, I would like to treat a POP3 mailbox like a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.