OpMath

com.opmath.mail.lite
Class MailClient

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.opmath.mail.lite.MailClient
All Implemented Interfaces:
Runnable

public class MailClient
extends Thread

An email client accessible to any Java application.

The com.opmath.mail.lite.MailClient class provides a simple email client. The client can send email using any named SMPT mail host. The client always logs send activity to the give PrintStream log.

NOTE 1: This version of com.opmath.mail.lite.MailClient does not support the receiving of IMAP or POP3 mail. Future versions might.

NOTE 2: The com.opmath.mail.lite package requires at least JavaMail 1.1.3 and the Java Activation Framework (JAF) 1.0.1.

Copyright: (c) 2003 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.4.1
Version:
1.0
Author:
Bruno Beloff bruno.beloff@opmath.com

Fields inherited from class java.lang.Thread
inheritableThreadLocals, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, threadLocals
 
Constructor Summary
MailClient(String server, String from, String fromName, PrintStream log)
          Constructs an MailClient instance with a given client 'identity'.
MailClient(String server, String from, String fromName, String filePath, PrintStream log)
          Constructs an MailClient instance with a given client 'identity'.
 
Method Summary
 MailMessage send(String subject, String to, String cc, String bcc, String text)
          Sends an email message.
 MailMessage send(String subject, String to, String cc, String bcc, String text, String fileName, String mimeType)
          Sends an email message.
 String toString()
          Returns a String describing the queue.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MailClient

public MailClient(String server,
                  String from,
                  String fromName,
                  PrintStream log)
           throws javax.mail.MessagingException
Constructs an MailClient instance with a given client 'identity'. The identity is in the form of a 'From:' email address and 'From:' personal name. The local file path for attachments is set as the local directory.
Parameters:
from - the String carrying the 'From:' address.
fromName - the String carrying the 'From:' personal name.
log - the PrintStream for the activity log.
Throws:
javax.mail.MessagingException - If the from address was not well-formed.

MailClient

public MailClient(String server,
                  String from,
                  String fromName,
                  String filePath,
                  PrintStream log)
           throws javax.mail.MessagingException
Constructs an MailClient instance with a given client 'identity'. The identity is in the form of a 'From:' email address and 'From:' personal name. The local file path for attachments is set according to the parameter filePath.
Parameters:
from - the String carrying the 'From:' address.
fromName - the String carrying the 'From:' personal name.
fromName - the String carrying the file path (with trailing '/').
log - the PrintStream for the activity log.
Throws:
javax.mail.MessagingException - If the from address was not well-formed.
Method Detail

send

public MailMessage send(String subject,
                        String to,
                        String cc,
                        String bcc,
                        String text,
                        String fileName,
                        String mimeType)
                 throws javax.mail.MessagingException
Sends an email message. The message carries an attachment, which is a file. The MIME type of this file attachment must be specified.

There are only three obligatory parameters for this send(..) method:

Where a paremeter value is not required, it may be given as null.

Parameters:
subject - a String subject text, or null.
to - a String list of email addresses.
cc - a String list of email addresses, or null.
bcc - a String list of email addresses, or null.
text - a String ascii plain text message, or null.
fileName - a String name for one attachment file.
mimeType - a String MIME type identifier, for the attachment.
Returns:
the MailMessage constructed as part of the queueing operation.
Throws:
javax.mail.MessagingException - If the email message could not be sent.

send

public MailMessage send(String subject,
                        String to,
                        String cc,
                        String bcc,
                        String text)
                 throws javax.mail.MessagingException
Sends an email message.

There is only one obligatory parameter for this queue(..) method:

Where a paremeter value is not required, it may be given as null.

Parameters:
subject - a String subject text, or null.
to - a String list of email addresses.
cc - a String list of email addresses, or null.
bcc - a String list of email addresses, or null.
text - a String ascii plain text message, or null.
Returns:
the MailMessage constructed as part of the queueing operation.
Throws:
javax.mail.MessagingException - If the email message could not be sent.

toString

public String toString()
Returns a String describing the queue.

Overrides:
toString in class Thread
Returns:
a String reporting the state of this MailClient.

OpMath

Submit a bug or feature to Open Math
Copyright © 2003 Open Math Company Limited, Brighton, UK