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.

 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 34
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%.

IBM Brings Developers Into the Cloud
Apache at 10: You Can't Buy Us
Microsoft's CodePlex Foundation Moving Forward
Apple Claims 100,000 Apps, Google Analyzes Them
Nokia Latest to Play Opera Mobile 10 Browser
PayPal Opens Up Payment Platform to Devs
Ubuntu Linux 9.10 'Karmic Koala' Starts Its Climb
IBM Links Rational Developer Tools, Tivoli Apps
Libraries Give Vista Apps a Windows 7 Look
Ubuntu: The 'Default Alternative' to Windows?

Delivering Web-based Embedded Fonts in CSS 3
Adobe Helps PHP Developers Create Rich Internet Applications
Java Developers Finding a Home at Adobe Flex
Virtualization Delivers a Dynamic Infrastructure
Consuming XML Web Services in iPhone Applications
Build a More Agile Business with IBM
POJO-Based Solutions for LDAP Access: One Good, One Better
IBM Offers Enhanced Measurement and Management for Energy Usage
IBM Helps Transformation to an Information-Based Enterprise
Top Five Touch UI-Related Design Guidelines

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs