advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

JavaBoutique : Articles : An Email Component

Contents
Introduction
Introduction to the SMTP Protocol
Creating the Client
Creating a Driver Program and Testing the Client
Converting to Java Version 1.1 or 1.2
Conclusions

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 ->

How to Add Java Applets to Your Site

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.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs