Purple Code

com.purpletech.net
Class Qsmtp

java.lang.Object
  |
  +--com.purpletech.net.Qsmtp

public class Qsmtp
extends java.lang.Object

SMTP client. Based on code by James Driscoll maus@io.com.

Qsmtp Class

by Alex Chaffee, Purple Technology

This class provides a quick and dirty way to send email from any Java program (including servlets and applets). It is based on the Qsmtp class by Jim Driscoll, but I've added the ability to add multiple recipients and extra headers.

Note: You may want to remove the package statement so it will compile correctly inside the root directory of your project.

Files

Download the source code.

See also:

Author:
James Driscoll maus@io.com, Alex alex@purpletech.com

Field Summary
protected  java.util.Dictionary headers
           
protected  java.lang.String host
           
protected  java.io.DataInputStream reply
           
protected  java.io.PrintStream send
           
protected  java.net.Socket sock
           
 
Constructor Summary
Qsmtp(java.net.InetAddress address)
           
Qsmtp(java.net.InetAddress address, int port)
           
Qsmtp(java.lang.String hostid)
          Create a Qsmtp object pointing to the specified host
Qsmtp(java.lang.String hostid, int port)
           
 
Method Summary
 void addTo(java.lang.String address)
           
 void close()
           
protected  void finalize()
           
 java.lang.String getHost()
           
 void initHeaders()
           
 void sendmsg(java.lang.String message)
           
 void sendmsg(java.lang.String from, java.lang.String to, java.lang.String subject, java.lang.String message)
           
 void setHeader(java.lang.String name, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

protected java.lang.String host

reply

protected java.io.DataInputStream reply

send

protected java.io.PrintStream send

sock

protected java.net.Socket sock

headers

protected java.util.Dictionary headers
Constructor Detail

Qsmtp

public Qsmtp(java.lang.String hostid)
      throws java.net.UnknownHostException,
             java.io.IOException
Create a Qsmtp object pointing to the specified host

Parameters:
hostid - The host to connect to.
Throws:
java.net.UnknownHostException
java.io.IOException

Qsmtp

public Qsmtp(java.lang.String hostid,
             int port)
      throws java.net.UnknownHostException,
             java.io.IOException

Qsmtp

public Qsmtp(java.net.InetAddress address)
      throws java.io.IOException

Qsmtp

public Qsmtp(java.net.InetAddress address,
             int port)
      throws java.io.IOException
Method Detail

getHost

public java.lang.String getHost()

initHeaders

public void initHeaders()

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)

addTo

public void addTo(java.lang.String address)

sendmsg

public void sendmsg(java.lang.String from,
                    java.lang.String to,
                    java.lang.String subject,
                    java.lang.String message)
             throws java.io.IOException,
                    java.net.ProtocolException
java.io.IOException
java.net.ProtocolException

sendmsg

public void sendmsg(java.lang.String message)
             throws java.io.IOException,
                    java.net.ProtocolException
java.io.IOException
java.net.ProtocolException

close

public void close()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
java.lang.Throwable

Documentation generated March 5 2003