I am trying to send a mail from Solaris 5.9 using JAVA code.but when I am trying to do the same.then I am not able to read a line(data) from buffer..I am only able to connect to SMTP server but not able to get the data from buffer.
when I am trying to read the line --
I am trying to read a line but unable to read it--
LineIn = In.readLine();
Please help me to resolve it.
Thanks in advance...
When posting code, consider the following:
- limiting the posted code to the bits actually used (several methods posted are never used)
- use normal Java naming conventions (classes, not local variables, begin with capital letters)
- post only code that will compile (this won't)
- remove superfluous code (what's the purpose of the first several lines of sendEmail()? It just obfuscates any actual issues.)
Yes,you are right and I can use Javamail or comm api but I want to know what is going wrong in this code so that I am not able to read the data and not able to send mail.
Please help me to understand it.
Thanks in advance ...
Quite often in network programming what you are writing will interact with a variety of operating systems and servers/clients written in many different programming languages. This requires special care. I recommend going over the Network and IO trails here. Another good resource is Java Network Programming by Elliot Harold, it talks about sockets, IO, threads and other critical topics in detail.
I disagree with the idea to use JavaMail. Nothing teaches you how email works(or whatever else you are wanting to learn) if you do it yourself. It makes you a self-reliant programmer. Of course, I wouldn't advise rolling you own for production use unless you really know what you are doing. Same goes for any protocol, data structure, etc.
Rusty Shackleford wrote:I disagree with the idea to use JavaMail. Nothing teaches you how email works(or whatever else you are wanting to learn) if you do it yourself. It makes you a self-reliant programmer. Of course, I wouldn't advise rolling you own for production use unless you really know what you are doing. Same goes for any protocol, data structure, etc.
It depends on what your goal is. If you are writing a program just for educational purposes, then I wouldn't have a problem with trying to implement the low-level e-mail protocol yourself. If this is a program for a project for work, then it's silly to implement it yourself when there are well-tested libraries available - trying to implement it yourself in that case will cost you more time and your own implementation will most likely be inferior to that of a well-known and well-tested library.
It isn't always the case that "existing and 'well' tested libraries" are better. For example there are cases where writing your own data structures is better then using what is in Collections. But I agree that generally using existing solutions is better and said exactly that in my first post.