Class GreenMailUtil

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

public class GreenMailUtil extends Object
Since:
Jan 29, 2006 Changed newMimeMessage(String param) for UTF-8 support.
Version:
$Id: $
Author:
Wael Chatila
  • Method Details

    • 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 javax.mail.internet.MimeMessage newMimeMessage(InputStream inputStream)
      Convenience method which creates a new MimeMessage from an input stream
    • newMimeMessage

      public static javax.mail.internet.MimeMessage newMimeMessage(String mailString) throws javax.mail.MessagingException
      Convenience method which creates a new MimeMessage from a string
      Throws:
      javax.mail.MessagingException
    • hasNonTextAttachments

      public static boolean hasNonTextAttachments(javax.mail.Part m)
    • getLineCount

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

      public static String getBody(javax.mail.Part msg)
      Returns:
      The content of an email (or a Part)
    • getHeaders

      public static String getHeaders(javax.mail.Part msg)
      Returns:
      The headers of an email (or a Part)
    • getWholeMessage

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

      public static byte[] getBodyAsBytes(javax.mail.Part msg)
    • getHeaderAsBytes

      public static byte[] getHeaderAsBytes(javax.mail.Part part)
    • toString

      public static String toString(javax.mail.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(javax.mail.Address[] addresses)
    • sendTextEmail

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

      public static javax.mail.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 javax.mail.MessagingException, IOException
      Throws:
      javax.mail.MessagingException
      IOException
    • convertUidsToIdRangeArray

      public static IdRange[] convertUidsToIdRangeArray(List<Long> uids)
    • uidsToRangeString

      public static String uidsToRangeString(List<Long> uids)
    • idRangeToString

      public static String idRangeToString(IdRange idRange)
    • idRangesToString

      public static String idRangesToString(IdRange[] idRanges)