public class GreenMail extends ConfiguredGreenMail
Constructor and Description |
---|
GreenMail()
Creates 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 only
|
GreenMail(ServerSetup[] config)
Call this constructor if you want to run more than one of the email servers
|
Modifier and Type | Method and Description |
---|---|
ImapServer |
getImap() |
ImapServer |
getImaps() |
Managers |
getManagers() |
Pop3Server |
getPop3() |
Pop3Server |
getPop3s() |
javax.mail.internet.MimeMessage[] |
getReceivedMessages() |
javax.mail.internet.MimeMessage[] |
getReceivedMessagesForDomain(String domain)
This method can be used as an easy 'catch-all' mechanism.
|
javax.mail.internet.MimeMessage[] |
getReceviedMessagesForDomain(String domain)
Deprecated.
As of 1.5 and to be removed in 1.6. Use
getReceivedMessagesForDomain(String domain) instead. |
SmtpServer |
getSmtp() |
SmtpServer |
getSmtps() |
void |
purgeEmailFromAllMailboxes()
Remove/purge all data from all mail stores (POP3/IMAP)
|
void |
reset()
Restart the GreenMail server.
|
void |
setQuotaSupported(boolean isEnabled)
Toggles the IMAP quota support.
|
GreenMailUser |
setUser(String login,
String password)
Sets the password for the account linked to email.
|
GreenMailUser |
setUser(String email,
String login,
String password)
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/login and the value the password
|
void |
start()
Start the GreenMail server
|
void |
stop()
Stop the GreenMail server.
|
GreenMailUtil |
util()
Deprecated.
As of 1.5 and to be removed in 1.6. No need to instantiate static helper class
|
boolean |
waitForIncomingEmail(int emailCount)
Does the same thing as
GreenMailOperations.waitForIncomingEmail(long, int) but with a default timeout of 5000ms |
boolean |
waitForIncomingEmail(long timeout,
int emailCount)
Use this method if you are sending email in a different thread from the one you're testing from.
|
GreenMail |
withConfiguration(GreenMailConfiguration config)
Configure GreenMail instance using the given configuration
|
doConfigure
public GreenMail()
ServerSetupTest
public GreenMail(ServerSetup config)
config
- Server setup to usepublic GreenMail(ServerSetup[] config)
config
- Server setup to usepublic void start()
GreenMailOperations
public void stop()
GreenMailOperations
public void reset()
GreenMailOperations
public SmtpServer getSmtp()
public ImapServer getImap()
public Pop3Server getPop3()
public SmtpServer getSmtps()
public ImapServer getImaps()
public Pop3Server getPop3s()
public Managers getManagers()
public boolean waitForIncomingEmail(long timeout, int emailCount)
GreenMailOperations
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 returningpublic boolean waitForIncomingEmail(int emailCount)
GreenMailOperations
GreenMailOperations.waitForIncomingEmail(long, int)
but with a default timeout of 5000msemailCount
- waits for these many emails to arrive before returningpublic javax.mail.internet.MimeMessage[] getReceivedMessages()
GreenMailUtil
has a bunch of static helper methods to extract body text etc.@Deprecated public javax.mail.internet.MimeMessage[] getReceviedMessagesForDomain(String domain)
getReceivedMessagesForDomain(String domain)
instead.domain
- the domainpublic javax.mail.internet.MimeMessage[] getReceivedMessagesForDomain(String domain)
GreenMailOperations
domain
- the domainpublic GreenMailUser setUser(String login, String password)
GreenMailOperations
login
- Login for which the password should be set. This is assumed to be the same as the email address.password
- New passwordpublic GreenMailUser setUser(String email, String login, String password)
GreenMailOperations
email
- Email address for which the password should be setlogin
- Login name for login. This may be different to the email address. E.g. the email address could be
"info@localhost", the login could be "info".password
- New passwordpublic void setQuotaSupported(boolean isEnabled)
GreenMailOperations
isEnabled
- true, if quotas should be supported.public void setUsers(Properties users)
GreenMailOperations
users
- User/password mappublic GreenMail withConfiguration(GreenMailConfiguration config)
GreenMailOperations
withConfiguration
in interface GreenMailOperations
withConfiguration
in class ConfiguredGreenMail
config
- Configuration to usepublic void purgeEmailFromAllMailboxes() throws FolderException
GreenMailOperations
FolderException
- on error@Deprecated public GreenMailUtil util()
Copyright © 2006–2017 Icegreen Technologies. All rights reserved.