LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2007, 12:51 AM   #1
amit_pansuria
Member
 
Registered: Sep 2006
Posts: 73

Rep: Reputation: 15
how to retrieve and read email from mailserver using ourown application


Helo
my applicatin setup is given below.
my pc which is running on fedora 6 which is connected to local mailserver(pop3) via LAN.

now i want to write application in my fedora pc which retrieve my mails
from mailserver and application is able to read this email.
i m using c++ language.
another approach is
if above is not possible then
after my email comes from mailserver to my personalaccount (fedora pc)
i want to write application which retrieve email from my user account and want to read it from my application .

Plz help me
best Regards,
Amit
 
Old 06-07-2007, 01:48 AM   #2
HowDoIProgramIt
Member
 
Registered: Nov 2006
Location: East Coast, USA (in "the great northeast")
Distribution: Custom / from source; Fedora, Debian, CentOS, Scientific; LFS.
Posts: 94

Rep: Reputation: 15
Quote:
i want to write application in my fedora pc which retrieve my mails
from mailserver and application is able to read this email.
i m using c++ language.
another approach is
if above is not possible then
after my email comes from mailserver to my personalaccount (fedora pc)
i want to write application which retrieve email from my user account and want to read it from my application .
If I'm understanding you correctly, you're wanting to access your POP, IMAP, etc. email server programatically and thus retrieve your email... If that's correct, and your e-mail server provides POP access to messages stored on it (either directly or otherwise), and, you don't have to deal with SSL (at least, not at first; that would significantly complicate any such application), an app such as what I think you're describing is pretty straightforward to write.

First, I would suggest locating, obtaining and reading the RFC(s) (I'm not gonna tell you which one(s); finding out that information is part of the process) that pertain to sending and receiving electronic mail (hint: search for author last name = "Postel").

Then, get your app logic down with telnet (you type the lines that don't begin with '+'):

Code:
$ telnet some.pop.server 110
+OK A POP server somewhere ...
USER user@host.net
+OK Password Required
PASS password
+OK Maildrop locked, ready; 23405 bytes in 22 messages.
STAT
+OK 22 23405
QUIT
+OK Have a nice day
Lastly, get yourself a good TCP/IP reference. I've found W. Richard Steven's "UNIX Network Progamming, Volume 1" to suit my needs quite well in this regard. Much of TCP/IP, etc. seems simple, but really isn't; for example, just establishing a TCP connection is a process that involves a "three-way handshake". There are a lot of "gotcha's" in socket programming; you'll probably also spot a number of aspects of TCP/IP that are potentially vulnerable to attacks, such as DOS/DDOS attacks.

When you're ready to move on to C / C++, you'll likely be using the sockets API; you establish your connection with the remote host, exchange data with the remotehost, and finally, close your connection with the remote host:

Code:
if (gethostbyname(nameOfMailServer))
{
   if (socket(...) < 0)
   {
      die();
   }

   if (connect(...) < 0)
   {
      die();
   }
}

Next, you'll exchange data with the server using send() and recv() or other calls:

Code:
send(socket,pData,strlen(pData),0);
...
recv(socket,pData,sizeof(pData),0);
At the end of your app, you'll want to close the correct socket(s) in the correct manner so that the connection with the remote host is shut down correctly; at this point, you'll either need to understand sockets or have a good reference.

Hope that's what you're trying to do & that this helps.

- Larry
 
Old 06-08-2007, 12:01 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Ask yourself "How is the application I am proposing different from any other mail reader?". From what you describe, the answer must be "Very little, maybe not at all". Perhaps you could explain in terms of the bigger picture what your objective is. There may very well be an existing application that serves your purpose.
If you still want to proceed, find out what mail server types your application needs to support: IMAP &/or POP. If the answer is POP, then you may want to make use of a pre-existing library to help you out; http://brouits.free.fr/libspopc/manual.html. If IMAP, then you should track down and used libimap and its associated documentation. With all due respect to HowDoIProgramIt, writing your own implementation of a POP or IMAP client library is probably not a challenge you want to take on.
If you have any knowledge of perl, you will find a number of existing modules that make mail retrieval fairly easy.
I assume you already have a working mail server to beat up on during your test & development cycle. I am pretty sure your ISP(s) don't want to be a testbed for your software.
--- rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Thunderbird won't retrieve email - time out error! Adrian Baker Linux - Software 2 11-27-2006 01:51 PM
Keeping e-mail in mailserver after they have been read george_milescu Linux - Software 0 12-01-2005 05:27 PM
Can't retrieve email Bond007 Linux - Networking 14 11-10-2005 02:26 PM
Retrieve internet email using Thunderbird? GT_Onizuka Linux - Software 1 06-28-2004 11:24 PM
How to retrieve email from cron scripts ? wallywood Linux - General 1 03-05-2004 03:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration