Package com.icegreen.greenmail.util
Class GreenMail
java.lang.Object
com.icegreen.greenmail.util.GreenMail
- Direct Known Subclasses:
Servers
- Since:
- Jan 28, 2006
- Version:
- $Id: $
- Author:
- Wael Chatila
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a SMTP, SMTPS, POP3, POP3S, IMAP, and IMAPS server binding onto non-default ports.GreenMail
(ServerSetup config) Call this constructor if you want to run one of the email servers onlyGreenMail
(ServerSetup[] config) Call this constructor if you want to run more than one of the email servers -
Method Summary
Modifier and TypeMethodDescriptiongetImap()
getImaps()
getPop3()
getPop3s()
javax.mail.internet.MimeMessage[]
getSmtp()
getSmtps()
Sets the password for the account linked to email.void
setUsers
(Properties users) Sets up accounts with password based on a properties map where the key is the email and the value the passwordvoid
start()
void
stop()
util()
boolean
waitForIncomingEmail
(int emailCount) Does the same thing asObject.wait(long, int)
but with a timeout of 5000msboolean
waitForIncomingEmail
(long timeout, int emailCount) Use this method if you are sending email in a different thread from the one you're testing from.
-
Constructor Details
-
GreenMail
public GreenMail()Creates a SMTP, SMTPS, POP3, POP3S, IMAP, and IMAPS server binding onto non-default ports. The ports numbers are defined inServerSetupTest
-
GreenMail
Call this constructor if you want to run one of the email servers only- Parameters:
config
-
-
GreenMail
Call this constructor if you want to run more than one of the email servers- Parameters:
config
-
-
-
Method Details
-
start
public void start() -
stop
public void stop() -
getSmtp
-
getImap
-
getPop3
-
getSmtps
-
getImaps
-
getPop3s
-
getManagers
-
waitForIncomingEmail
Use this method if you are sending email in a different thread from the one you're testing from. Block waits for an email to arrive in any mailbox for any user. Implementation Detail: No polling wait implementation- Parameters:
timeout
- maximum time in ms to wait for emailCount of messages to arrive before giving up and returning falseemailCount
- waits for these many emails to arrive before returning- Returns:
- Returns false if timeout period was reached, otherwise true.
- Throws:
InterruptedException
-
waitForIncomingEmail
Does the same thing asObject.wait(long, int)
but with a timeout of 5000ms- Parameters:
emailCount
-- Returns:
- Throws:
InterruptedException
-
getReceivedMessages
public javax.mail.internet.MimeMessage[] getReceivedMessages()- Returns:
- Returns all messags in all folders for all users
GreenMailUtil
has a bunch of static helper methods to extract body text etc.
-
setUser
Sets the password for the account linked to email. If no account exits, one is automatically created when an email is received The automatically created account has the account login and password equal to the email address.- Parameters:
email
-password
-
-
setUser
-
setUsers
Sets up accounts with password based on a properties map where the key is the email and the value the password- Parameters:
users
-
-
util
-