CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Surface level...what if and how difficult

 



benn600
User


Sep 30, 2005, 6:45 AM

Post #1 of 3 (816 views)
Surface level...what if and how difficult Can't Post

How difficult would it be to write a simple email retrieval program? I have my own email server which has an http email client but it is only a demo and it will probably expire after a short while. Therefore, I'd like to see if I could make my own client. Can someone summarize how difficult this would be in general terms? I am learning mysql now and am starting to get above-beginner with it, so this would make the site a little easier. Also, I have a question about how to store messages:

This question can be asked more easily by applying the concept to a message board/forum. When messages are stored, are they ALL stored in one single table/entity? And then each instance/entry will just have a foreign key specifying which thread it is in? The thread names would be listed in another entity. Is this the general form? I used to use .txt files and I even made a somewhat useful forum of my own but I use a method that most forums probably don't use. Each time a new thread is created, a new .txt file is created. Then, when the admin deletes a thread, that file is deleted and the thread name is deleted from the thread list. I don't think this is a common way to store data in a mysql database, though, because you would have a table for every thread--making SHOW DATABASES; absolutely huge over time. Does having one table end up slowing the database down because each thread opened has to scan the entire table for messages with thread id of 53?

Thanks!
----------------------------------------------------------------------------
Wink http://www.ppcpathways.com/ Wink
Visit my new site devoted to reviewing the latest pocketpc products and news that I built in cgi-perl!


rork
User

Oct 1, 2005, 12:58 AM

Post #2 of 3 (807 views)
Re: [benn600] Surface level...what if and how difficult [In reply to] Can't Post

A simple email client is easy to make, you have to use Net::POP3 if you have a pop3 server or a module for using IMAP. I made one like this.

Well, simple it is: download the messages and read them, but what if you get an email with attachments? You have to use the Mime:: package to handle these which is a bit more complicated. There was a tutorial somewhere on the internet.

There are also some free http email clients I thought, consider using one of them.

For your forum question: I'd use a table, give all messages an ID (use autoincrement so it won't double) and give the reply a parent id. Now you can look them up with 'id = $id AND parent = $id' sort them on date or id and display. It works fast and SQL shouldn;t have problems looking through a lot of data in one table.
--
Don't reinvent the wheel, use it, abuse it or hack it.


davorg
Thaumaturge / Moderator

Oct 3, 2005, 3:22 AM

Post #3 of 3 (803 views)
Re: [benn600] Surface level...what if and how difficult [In reply to] Can't Post


In Reply To
How difficult would it be to write a simple email retrieval program? I have my own email server which has an http email client but it is only a demo and it will probably expire after a short while. Therefore, I'd like to see if I could make my own client. Can someone summarize how difficult this would be in general terms? I am learning mysql now and am starting to get above-beginner with it, so this would make the site a little easier.


Writing an email application is harder than you might think. Which is why most webmail programs are so bad.

Oh, it's simple enough to download messages using Net::POP3 or Net::IMAP but the problem comes when you get MIME-encoded attachments.

There are also a whole load of new problems when it comes to composing new mail. Do you understand all the mail headers that you should create? For example, can you explain the difference between the 'References' and 'In-Reply-To' headers.

If you're serious about this then take a look at the Perl Email Project. They are building a simple and consistant set of modules for handling email messages.


In Reply To
This question can be asked more easily by applying the concept to a message board/forum. When messages are stored, are they ALL stored in one single table/entity? And then each instance/entry will just have a foreign key specifying which thread it is in? The thread names would be listed in another entity. Is this the general form? I used to use .txt files and I even made a somewhat useful forum of my own but I use a method that most forums probably don't use. Each time a new thread is created, a new .txt file is created. Then, when the admin deletes a thread, that file is deleted and the thread name is deleted from the thread list. I don't think this is a common way to store data in a mysql database, though, because you would have a table for every thread--making SHOW DATABASES; absolutely huge over time. Does having one table end up slowing the database down because each thread opened has to scan the entire table for messages with thread id of 53?


You would have one table that contains all of your messages. Each message would have (amongst other things) a unique id and a column containing the id of its parent message. Top level messages would have an id of 0. It's therefore simple to create a query that brings back a) all top level queries (i.e. all conversations on the messageboard) and b) all children of a given query.

Having indexes on both of these tables would help to make these queries as fast as possible.

Once again I should point out that discussion of database modelling and query optimaisation isn't really what this board is for so you might well be better off finding a board that specialises in these topics.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives