Package com.icegreen.greenmail.spring
Class GreenMailBean
- java.lang.Object
-
- com.icegreen.greenmail.spring.GreenMailBean
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean
public class GreenMailBean extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.BeanNameAware
Spring bean for GreenMail server.By default,
- SMTP, POP3 services are activated
- autostart is enabled
- port offset is 3000
- Author:
- Marcel May (mm)
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.LoggerlogNew logger.
-
Constructor Summary
Constructors Constructor Description GreenMailBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).voiddestroy()Invoked by a BeanFactory on destruction of a singleton.GreenMailgetGreenMail()Getter for property 'greenMail'.StringgetHostname()Getter for property 'hostname'.intgetPortOffset()Getter for property 'portOffset'.jakarta.mail.internet.MimeMessage[]getReceivedMessages()Gets the currently received messages.longgetServerStartupTimeout()Timeout to wait for server startup in millisUserManagergetUserManager()Convenience method for directly accessing UserManager.List<String>getUsers()Getter for property 'users'.booleanisAutostart()Getter for property 'autostart'.booleanisImapProtocol()Getter for property 'imapProtocol'.booleanisImapsProtocol()Getter for property 'imapsProtocol'.booleanisPop3Protocol()Getter for property 'pop3Protocol'.booleanisPop3sProtocol()Getter for property 'pop3sProtocol'.booleanisSmtpProtocol()Getter for property 'smtpProtocol'.booleanisSmtpsProtocol()Getter for property 'smtpsProtocol'.booleanisStarted()Getter for property 'started'.voidsendEmail(String theTo, String theFrom, String theSubject, String theContent)Sends a mail message to the GreenMail server.voidsetAutostart(boolean theAutostart)Sets the autostart flag.voidsetBeanName(String pName)voidsetHostname(String pHostname)Setter for property 'hostname'.voidsetImapProtocol(boolean theImapProtocoll)Setter for property 'imapProtocol'.voidsetImapsProtocol(boolean theImapsProtocoll)Setter for property 'imapsProtocol'.voidsetPop3Protocol(boolean thePop3Protocoll)Setter for property 'pop3Protocol'.voidsetPop3sProtocol(boolean thePop3sProtocoll)Setter for property 'pop3sProtocol'.voidsetPortOffset(int pPortOffset)Setter for property 'portOffset'.voidsetServerStartupTimeout(long serverStartupTimeout)voidsetSmtpProtocol(boolean theSmtpProtocoll)Setter for property 'smtpProtocol'.voidsetSmtpsProtocol(boolean theSmtpsProtocoll)Setter for property 'smtpsProtocol'.voidsetUsers(List<String> theUsers)Setter for property 'users'.voidstart()Starts the server.voidstop()Stops the server.
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws ExceptionInvoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails.
-
start
public void start()
Starts the server.
-
stop
public void stop()
Stops the server.
-
getReceivedMessages
public jakarta.mail.internet.MimeMessage[] getReceivedMessages()
Gets the currently received messages.- Returns:
- the available messages.
-
destroy
public void destroy() throws ExceptionInvoked by a BeanFactory on destruction of a singleton.- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception- in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources too.
-
setAutostart
public void setAutostart(boolean theAutostart)
Sets the autostart flag.- Parameters:
theAutostart- the flag.
-
isAutostart
public boolean isAutostart()
Getter for property 'autostart'.- Returns:
- Value for property 'autostart'.
-
setSmtpProtocol
public void setSmtpProtocol(boolean theSmtpProtocoll)
Setter for property 'smtpProtocol'.- Parameters:
theSmtpProtocoll- Value to set for property 'smtpProtocol'.
-
isSmtpProtocol
public boolean isSmtpProtocol()
Getter for property 'smtpProtocol'.- Returns:
- Value for property 'smtpProtocol'.
-
setSmtpsProtocol
public void setSmtpsProtocol(boolean theSmtpsProtocoll)
Setter for property 'smtpsProtocol'.- Parameters:
theSmtpsProtocoll- Value to set for property 'smtpsProtocol'.
-
isSmtpsProtocol
public boolean isSmtpsProtocol()
Getter for property 'smtpsProtocol'.- Returns:
- Value for property 'smtpsProtocol'.
-
setPop3Protocol
public void setPop3Protocol(boolean thePop3Protocoll)
Setter for property 'pop3Protocol'.- Parameters:
thePop3Protocoll- Value to set for property 'pop3Protocol'.
-
isPop3Protocol
public boolean isPop3Protocol()
Getter for property 'pop3Protocol'.- Returns:
- Value for property 'pop3Protocol'.
-
setPop3sProtocol
public void setPop3sProtocol(boolean thePop3sProtocoll)
Setter for property 'pop3sProtocol'.- Parameters:
thePop3sProtocoll- Value to set for property 'pop3sProtocol'.
-
isPop3sProtocol
public boolean isPop3sProtocol()
Getter for property 'pop3sProtocol'.- Returns:
- Value for property 'pop3sProtocol'.
-
setImapProtocol
public void setImapProtocol(boolean theImapProtocoll)
Setter for property 'imapProtocol'.- Parameters:
theImapProtocoll- Value to set for property 'imapProtocol'.
-
isImapProtocol
public boolean isImapProtocol()
Getter for property 'imapProtocol'.- Returns:
- Value for property 'imapProtocol'.
-
setImapsProtocol
public void setImapsProtocol(boolean theImapsProtocoll)
Setter for property 'imapsProtocol'.- Parameters:
theImapsProtocoll- Value to set for property 'imapsProtocol'.
-
isImapsProtocol
public boolean isImapsProtocol()
Getter for property 'imapsProtocol'.- Returns:
- Value for property 'imapsProtocol'.
-
setHostname
public void setHostname(String pHostname)
Setter for property 'hostname'.- Parameters:
pHostname- Value to set for property 'hostname'.
-
getHostname
public String getHostname()
Getter for property 'hostname'.- Returns:
- Value for property 'hostname'.
-
setPortOffset
public void setPortOffset(int pPortOffset)
Setter for property 'portOffset'.- Parameters:
pPortOffset- Value to set for property 'portOffset'.
-
getPortOffset
public int getPortOffset()
Getter for property 'portOffset'.- Returns:
- Value for property 'portOffset'.
-
getUserManager
public UserManager getUserManager()
Convenience method for directly accessing UserManager.- Returns:
- the user manager.
-
setUsers
public void setUsers(List<String> theUsers)
Setter for property 'users'.- Parameters:
theUsers- Value to set for property 'users'.
-
getUsers
public List<String> getUsers()
Getter for property 'users'.- Returns:
- Value for property 'users'.
-
isStarted
public boolean isStarted()
Getter for property 'started'.- Returns:
- Value for property 'started'.
-
getGreenMail
public GreenMail getGreenMail()
Getter for property 'greenMail'.- Returns:
- Value for property 'greenMail'.
-
sendEmail
public void sendEmail(String theTo, String theFrom, String theSubject, String theContent)
Sends a mail message to the GreenMail server.Note: SMTP or SMTPS must be configured.
- Parameters:
theTo- the TO field.theFrom- the FROMfield.theSubject- the subject.theContent- the message content.
-
setBeanName
public void setBeanName(String pName)
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
getServerStartupTimeout
public long getServerStartupTimeout()
Timeout to wait for server startup in millis- Returns:
- Value for property 'serverStartupTimeout'
-
setServerStartupTimeout
public void setServerStartupTimeout(long serverStartupTimeout)
-
-