public class MailSessionManager extends Object
Constructor and Description |
---|
MailSessionManager(Logger log) |
Modifier and Type | Method and Description |
---|---|
void |
closeFolderAndStore(javax.mail.Folder folder,
javax.mail.Store store,
boolean expunge)
Close previously opened folder and store. folder is expunged if needed
|
javax.mail.Session |
createSessionPropertiesFromDescriptor(ConsumeDescriptor consumeDescriptor)
Create a
Properties object with given properties. |
javax.mail.Session |
createSessionPropertiesFromDescriptor(ProvideDescriptor provideDescriptor)
Create a
Properties object with given properties. |
javax.mail.Folder |
getFolderAndOpen(javax.mail.Store store,
ConsumeDescriptor consumeDescriptor)
Retrieve a specified
Folder from the given Store and open it. |
List<javax.mail.Message> |
getNewMails(javax.mail.Folder folder)
Retrieve new mails into the given folder.
|
javax.mail.Store |
getStoreAndConnect(javax.mail.Session session,
ConsumeDescriptor consumeDescriptor)
Retrieve a
Store from the given Session. |
void |
sendMail(javax.mail.internet.MimeMessage mimeMessage,
ProvideDescriptor sessionDescriptor,
javax.mail.Session session)
Send an email based on the given MimeMessage
|
public MailSessionManager(Logger log)
log
- the component loggerpublic void closeFolderAndStore(javax.mail.Folder folder, javax.mail.Store store, boolean expunge)
folder
- the folder to closestore
- the store to closeexpunge
- public javax.mail.Session createSessionPropertiesFromDescriptor(ProvideDescriptor provideDescriptor)
Properties
object with given properties. Then create a new Session
initialized with the
given propertiesconsumeDescriptor
- a SessionDescriptor
build from an address URISession
public javax.mail.Session createSessionPropertiesFromDescriptor(ConsumeDescriptor consumeDescriptor)
Properties
object with given properties. Then create a new Session
initialized with the
given propertiesconsumeDescriptor
- a SessionDescriptor
build from an address URISession
public javax.mail.Folder getFolderAndOpen(javax.mail.Store store, ConsumeDescriptor consumeDescriptor) throws javax.mail.MessagingException
Folder
from the given Store
and open it.store
- the mail Store
consumeDescriptor
- the mail SessionDescriptor
Folder
javax.mail.MessagingException
public List<javax.mail.Message> getNewMails(javax.mail.Folder folder) throws javax.mail.MessagingException
folder
- the folder used to search for new mailjavax.mail.MessagingException
public javax.mail.Store getStoreAndConnect(javax.mail.Session session, ConsumeDescriptor consumeDescriptor) throws javax.mail.MessagingException
Store
from the given Session. Then connect to it.session
- the mail Session
consumeDescriptor
- the SessionDescriptor
associated to this sessionStore
javax.mail.MessagingException
javax.jbi.JBIException
- if error occurs during mail Store
retrievalpublic void sendMail(javax.mail.internet.MimeMessage mimeMessage, ProvideDescriptor sessionDescriptor, javax.mail.Session session) throws javax.mail.MessagingException
mimeMessage
- the MimeMessage
to send. The resulting email will conform to the RFC822 and MIME standardssessionDescriptor
- a SessionDescriptor
build from an address URIsession
- the mail Session
javax.mail.MessagingException
- if error occurs during message sendingTransport.send(javax.mail.Message);
Copyright © 2005-2018 Linagora. All Rights Reserved.