Hi All
With the support provided by maildemo8i in the sample code of oracle site i am able to send mail to my smtp server.
Any tutorial or links,how to read the folders of my mailbox which is in my mail server.

There are two basic protocols used for e-mailing. SMTP - Simple Mail Transfer Protocol. This is used to deliver an e-mail to a mail server for tranmission. And this is what UTL_SMTP implements.

The other protocol (used for fetching e-mails as oppose to delivering them) is called POP - Post Office Protocol. The current and most widely used version is called POP3.

It is not that difficult to use. Like SMTP is it a protocol to transport the e-mail cargo between client and server. It does not "display" an e-mail - once that e-mail cargo has arrived on your code's doorstep, you and your code need to process it.. determine the attachments, the contents, etc.

The POP protocol is described in [url http://www.faqs.org/rfcs/rfc1939.html]RFC1939.

A couple of comments.

POP3 is being replaced by IMAP (see RFC1730 Internet Message Access Protocol - Version 4). This is a more secure protocol than POP3 and has more features.

Microsoft Exchange can support both as far as I know. However, some anal Microsoft admins will disable both - which means you are pretty much screwed in that respect. In which case your only other alternative is to use MS Exchange's http/https interface. Like Ximian does for Evolution's MS Exchange plug-in (which works pretty well).

Do not start coding right away. First discover and learn POP3 basics. All you need is telnet (with local echo enabled in order to see what you type). A typical conversation with the POP3 server will be:
- logging on
- listing the number of messages
- retrieving a message
- deleting a retrieved message
- signing off

I would have liked to copy and pasted such a session for you, but unfortunately I deal with anal Microsoft Exchange admins. No POP3. No IMAP.

PS. to use telnet, do a telnet <mailserver> 110 and use the commands as described in RFC1939 above.

PPS. once you have the hang of this, use UTL_TCP and do the same sequence of commands.

Well, it not that "new" when one deals with network services and network applications a lot. And what makes many of the protocols easy to use and to play with, is that they are clear-text protocols. Which means that you can use telnet, connect to that network service, and carry a conversation with it manually.

As for Oracle being vast - true. But POP3 and even SMTP and HTTP, have very little to do with the Oracle database itself. What is kewl is that we can, from inside Oracle, use these application protocols. But I would not call these as "part" of the Oracle concepts and fundamentals.

Oh yeah - what makes Oracle so great is that you can develop a pipeline table function in Oracle that makes use of POP3 to retrieve an e-mail... and then you can simply use SQL to display an e-mail.

> I had no idea that pipeline function can be used for this purpose before until i saw this post.

I mostly use pipeline table functions in this fashion - SQL wrappers for other services.

This make it easy for the developers to use as they simply need to know and use SQL - and not be bothered with the protocols and other complexities of the service they're actually dealing with, under the hood.

Pipeline tables in this fashion is simply another form of external tables, but instead of a SQL*Loader wrapper for loading a CSV, it wraps a service like HTTP, POP3 and so on.

I am currently working on a package called UTL_IMAP which I will be releasing publicly very soon (i.e. within the next week).

The first version uses Java stored procedures and the JavaMail API to provide a fairly simple interface for accessing mailboxes.

I plan to make V2 a more complete implementation of RFC3501 using UTL_TCP to implement the protocol from the ground up. Hopefully this will improve the performance as my java implementation suffers from a fairly hefty initialisation delay.

Note that the trailing period is the end-of-message-body marker and not really part of the message body that the sender created.

PS. Oh yes - I defined a timeout exception and tried catching that to determine the eof for the message body, but ran into what seems to be an Oracle bug. However, simply checking whether there is data to read, using the UTL_TCP.Available() function, works great.