The following code is old. I haven't touched it in quite a while. It does offer the advantages of being free, public domain, and coming with source. However, if you'd like to see a bunch of GOOD, FREE classes for doing the same thing, as well as a number of other protocols, check out ORO, Inc. Good stuff there.
Java includes a very advanced API for network access. Sadly, Sun made a decision during the development process that the API's for such things as internet email, USENET news, and ftp were removed from the java.net.* hierarchy and placed in the sun.net.* hierarchy. I consider this tragic, since they are now undocumented and unsupported. Additionally, they will not be in VM's developed from scratch.
Currently, there are a few classes on this page. SmtpApp, Qsmtp, and Qpop. The Qsmtp (Quick SMTP) is finished, and implements a quick and easy SMTP class. Wouldn't know it, though - only a few pages of code. It works quite well however. An example implementation of this class is the SmtpApp class, which lets you send Internet Email to the Author (me). I've tried to make it safe, yet flexible enough to plug into your own page.
Use this class to send electronic mail quickly and easily... only 2 method calls, 3812 bytes of code, quickly downloaded, easily executed. This class is based on RFC821 and on RFC822.
Here's the source.
Just download the class file (you may have to shift-click or right-click to get this one).
public Qsmtp( String hostid) throws UnknownHostException, IOException
public Qsmtp( String hostid, int port) throws UnknownHostException, IOException
public Qsmtp( InetAddress address ) throws IOException
public Qsmtp( InetAddress address, int port ) throws IOException
public void sendmsg( String from_address, String to_address, String subject, String message )
throws IOException, ProtocolException
Here's how to use it -
Plug this class into your web page for a goofy little replacement for the mailto tag. Should be really just used as an example, and a basis for your own applets.
The pitifully simple sample implementation applet (took me only an evening to write!).
The applet class.
The applet source.
<APPLET CODE="SmtpApp.class" WIDTH=300 HEIGHT=200> Hey! Not much point in looking at Java applets without a browser that supports Java! Heck, for this one, just use the <A HREF="mailto:maus@io.com" >mailto</A>. But it won't be nearly as fun! <PARAM Name="To" Value="maus@li.net"> <PARAM Name="From" Value="maus@io.com"> <PARAM Name="Mailhost" Value="www.io.com"> <PARAM Name="EditFrom" Value="true"> <PARAM Name="EditTo" Value="false"> </APPLET>
Here's how to use it -
Enough people have been asking strange questions on the newsgroups about usage of the various network related classes that I thought that I'd put some samples up to point people to when they ask "How do I?" type questions.
Home Sweet Home.
This page last updated
This page has been accessed times since Aug 7, 1996.
This page is listed at Gamelan (isn't everyone's?)