Introduction to the SMTP Protocol
Important:
Most SMTP servers have SMTP relay disabled. What this means is that applets
that use the email component may not be able to send email to third parties.
In general, the applets can send email to a person with an account on the
server they were downloaded from, even if SMTP relaying is denied.
So if your email address is you@somedomain.com, and the applet was downloaded
from www.somedomain.com, the SMTP server at somedomain.com will generally
accept the email for you@somedomain.com, but not relay the email to somebody@someotherdomain.com.
SMTP servers will also generally relay messages from clients in a certain
IP range, so the SMTP class is also usable by code that is running on a
server on a LAN with an SMTP server on the LAN (I've used it a lot with
servlets with SMTP servers on localhost).
Here is how the protocol looks, as shown in RFC
821. The email component side of the conversation is shown beside
"emc:". the server side of the conversation is shown beside "serv:".
serv: 220 somewhere.com Simple Mail Transfer Service Ready
emc: HELO emc
serv: 250 somewhere.com
emc: MAIL FROM:<noone@nowhere.com>
serv: 250 OK
emc: RCPT TO:<someone@somewhere.com>
serv: 250 OK
emc: DATA
serv: 354 Start mail input; end with <CRLF>.<CRLF>
emc: Date: March 17, 2000 10:21
emc: From: The Sender <noone@nowhere.com>
emc: To: Some Recipient <someone@somewhere.com>
emc: Subject: This is just a test
emc:
emc: This is a test message
emc: .
serv: 250 OK
emc: QUIT
serv: 221 SMTP server closing transmission channel
There are five basic phases to this sort of simple
transfer of mail. At the beginning, the server identifies itself,
then the client identifies itself (they say hi). The success message
is 250 (250 starts the line). If you refer to the source code for
emc, you will see that it checks to make sure the message returned by the
server indicates that everything is ok. The next two phases are where
the client indicates who the mail is from and who the mail is for.
The success message is again 250 OK. This is where the message could
be something indicating a failure, for example, 552 Relay denied.
The next phase is where the email is actually sent. The header information
(date, subject, etc.) is sent first, followed by one blank line, then the
message, then a dot "." on a line by itself. Finally, the connection
is closed using a QUIT command.
Attachments could also be sent in the message,
but MIME attachments add quite a bit of complication to the email component
(not addressed here).
NEXT ->
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|