com.icegreen.greenmail.util
Class GreenMailUtil

java.lang.Object
  extended by com.icegreen.greenmail.util.GreenMailUtil

public class GreenMailUtil
extends Object

Since:
Jan 29, 2006
Version:
$Id: $
Author:
Wael Chatila

Method Summary
static void copyStream(InputStream src, OutputStream dest)
          Writes the content of an input stream to an output stream
static String getAddressList(Address[] addresses)
           
static String getBody(Part msg)
           
static byte[] getBodyAsBytes(Part msg)
           
static byte[] getHeaderAsBytes(Part part)
           
static String getHeaders(Part msg)
           
static int getLineCount(String str)
           
static Session getSession(ServerSetup setup)
           
static String getWholeMessage(Part msg)
           
static boolean hasNonTextAttachments(Part m)
           
static GreenMailUtil instance()
           
static MimeMessage newMimeMessage(InputStream inputStream)
          Convenience method which creates a new MimeMessage from an input stream
static MimeMessage newMimeMessage(String mailString)
          Convenience method which creates a new MimeMessage from a string
static String random()
          Generates a random generated password consisting of letters and digits with a length variable between 5 and 8 characters long.
static String random(int nbrOfLetters)
           
static void sendAttachmentEmail(String to, String from, String subject, String msg, byte[] attachment, String contentType, String filename, String description, ServerSetup setup)
           
static void sendTextEmail(String to, String from, String subject, String msg, ServerSetup setup)
           
static void sendTextEmailSecureTest(String to, String from, String subject, String msg)
           
static void sendTextEmailTest(String to, String from, String subject, String msg)
           
static String toString(Part msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static GreenMailUtil instance()

copyStream

public static void copyStream(InputStream src,
                              OutputStream dest)
                       throws IOException
Writes the content of an input stream to an output stream

Throws:
IOException

newMimeMessage

public static MimeMessage newMimeMessage(InputStream inputStream)
Convenience method which creates a new MimeMessage from an input stream


newMimeMessage

public static MimeMessage newMimeMessage(String mailString)
                                  throws MessagingException
Convenience method which creates a new MimeMessage from a string

Throws:
MessagingException

hasNonTextAttachments

public static boolean hasNonTextAttachments(Part m)

getLineCount

public static int getLineCount(String str)
Returns:
Returns the number of lines in any string

getBody

public static String getBody(Part msg)
Returns:
The content of an email (or a Part)

getHeaders

public static String getHeaders(Part msg)
Returns:
The headers of an email (or a Part)

getWholeMessage

public static String getWholeMessage(Part msg)
Returns:
The both header and body for an email (or a Part)

getBodyAsBytes

public static byte[] getBodyAsBytes(Part msg)

getHeaderAsBytes

public static byte[] getHeaderAsBytes(Part part)

toString

public static String toString(Part msg)
Returns:
same as getWholeMessage(javax.mail.Part) }

random

public static String random()
Generates a random generated password consisting of letters and digits with a length variable between 5 and 8 characters long. Passwords are further optimized for displays that could potentially display the characters 1,l,I,0,O,Q in a way that a human could easily mix them up.

Returns:

random

public static String random(int nbrOfLetters)

sendTextEmailTest

public static void sendTextEmailTest(String to,
                                     String from,
                                     String subject,
                                     String msg)

sendTextEmailSecureTest

public static void sendTextEmailSecureTest(String to,
                                           String from,
                                           String subject,
                                           String msg)

getAddressList

public static String getAddressList(Address[] addresses)

sendTextEmail

public static void sendTextEmail(String to,
                                 String from,
                                 String subject,
                                 String msg,
                                 ServerSetup setup)

getSession

public static Session getSession(ServerSetup setup)

sendAttachmentEmail

public static void sendAttachmentEmail(String to,
                                       String from,
                                       String subject,
                                       String msg,
                                       byte[] attachment,
                                       String contentType,
                                       String filename,
                                       String description,
                                       ServerSetup setup)
                                throws MessagingException,
                                       IOException
Throws:
MessagingException
IOException