Package com.icegreen.greenmail.util
Class GreenMailUtil
java.lang.Object
com.icegreen.greenmail.util.GreenMailUtil
- Since:
- Jan 29, 2006 Changed newMimeMessage(String param) for UTF-8 support.
- Version:
- $Id: $
- Author:
- Wael Chatila
-
Method Summary
Modifier and TypeMethodDescriptionstatic IdRange[]
convertUidsToIdRangeArray
(List<Long> uids) static void
copyStream
(InputStream src, OutputStream dest) Writes the content of an input stream to an output streamstatic String
getAddressList
(javax.mail.Address[] addresses) static String
getBody
(javax.mail.Part msg) static byte[]
getBodyAsBytes
(javax.mail.Part msg) static byte[]
getHeaderAsBytes
(javax.mail.Part part) static String
getHeaders
(javax.mail.Part msg) static int
getLineCount
(String str) static javax.mail.Session
getSession
(ServerSetup setup) static String
getWholeMessage
(javax.mail.Part msg) static boolean
hasNonTextAttachments
(javax.mail.Part m) static String
idRangesToString
(IdRange[] idRanges) static String
idRangeToString
(IdRange idRange) static GreenMailUtil
instance()
static javax.mail.internet.MimeMessage
newMimeMessage
(InputStream inputStream) Convenience method which creates a newMimeMessage
from an input streamstatic javax.mail.internet.MimeMessage
newMimeMessage
(String mailString) Convenience method which creates a newMimeMessage
from a stringstatic 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
(javax.mail.Part msg) static String
uidsToRangeString
(List<Long> uids)
-
Method Details
-
instance
-
copyStream
Writes the content of an input stream to an output stream- Throws:
IOException
-
newMimeMessage
Convenience method which creates a newMimeMessage
from an input stream -
newMimeMessage
public static javax.mail.internet.MimeMessage newMimeMessage(String mailString) throws javax.mail.MessagingException Convenience method which creates a newMimeMessage
from a string- Throws:
javax.mail.MessagingException
-
hasNonTextAttachments
public static boolean hasNonTextAttachments(javax.mail.Part m) -
getLineCount
- Returns:
- Returns the number of lines in any string
-
getBody
- Returns:
- The content of an email (or a Part)
-
getHeaders
- Returns:
- The headers of an email (or a Part)
-
getWholeMessage
- 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
- Returns:
- same as
getWholeMessage(javax.mail.Part)
}
-
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
-
sendTextEmailTest
-
sendTextEmailSecureTest
-
getAddressList
-
sendTextEmail
public static void sendTextEmail(String to, String from, String subject, String msg, ServerSetup setup) -
getSession
-
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
-
uidsToRangeString
-
idRangeToString
-
idRangesToString
-