Simple Java Mail Client
Hello Java community. I am taking an intro to java course and have run into a bunch of trouble towards the end. Our teacher has barely taught us anything about networking, or anything else for that matter lol, but he wants us to work on creating a java mail client. My friends and I have been working for sometime on this but have not gotten very far. We have searched online, through our textbook, and spoke to others and still are having trouble. I was wondering if you could give us any help. We also have not been taught on netbeans much, which he popped out of nowhere last class and said we had to use for a graphic interface. here is the hw question:
Design a mail client which will allow us to send one message while detecting any error that may occur during the process and telling the user. The screen shoudl have fields for SMTP server, Sender's email address, recipient's email address, and a text area for the body of the message.
SMTP usually uses port 25 for mail. You may provide an input box to override this default, though it's not necessary.
A transcript of a normal session is below:
220 duke.poly.edu ESMTP Sendmail 8.13.1/8.13.1; Wed, 16 Apr 2008 20:25:59 -0400 (EDT)
250 duke.poly.edu Hello dkatz@localhost [127.0.0.1], pleased to meet you
250 2.1.0 <email@example.com>... Sender ok
250 2.1.5 <firstname.lastname@example.org>... Recipient ok
354 Enter mail, end with "." on a line by itself
Subject: This is a test message
250 2.0.0 m3H0PxPp025632 Message accepted for delivery
You can try this yourself, by executing "telnet (mailserver) 25" in a command window.
-Any help would be much appreciated. Snippets of code, advice, or even the whole thing would be very helpful so that i can sort of "reverse engineer" it and see what has been done as i am very lost.
Did you read about JavaMail API. That's the solution for you.
You just got lucky... go here and steal that code... dont worry about the server, just take that code and get it compiled
Its not perfect but it does what you need.
As Eranga said its Javamail, but what you learning.. ie the smtp protocol is also a good thing, thats whats happening underneath Javamail... and Eranga, I got to tell you, if thats you, I think I'm in love ;)
The SMTP protocol for sending a message is pretty simple. You could use the JavaMail framework or just do a Google search for "Java SMTP". Plenty of results available.
Either way, to really understand you should look at RFC 821 which describes the protocol.