Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.hipermail
Class SessionHandler

    java.lang.Object
      com.knowgate.hipermail.SessionHandler

    public class SessionHandler

extends java.lang.Object

A wrapper around javax.mail.Store and javax.mail.Transport

Constructor Summary
`SessionHandler()` Default constructor
`SessionHandler(MailAccount oAccount)` Create instance taking data from a MailAccount The data of MailAccount stored at k_user_mail table is used for initializing the connection properties
`SessionHandler(MailAccount oAccount, java.lang.String sMBoxDirectory)` Create instance taking data from a MailAccount and set local directory for MBOX files
`SessionHandler(java.util.Properties oMailProperties)` Create session using given Properties

Method Summary
`void` | `close()`
`java.lang.String` | `getAccountName()` Get column incoming_account of k_user_mail
`java.lang.String` | `getAuthStr()` Get column incoming_password of k_user_mail
`Folder` | `getFolder(java.lang.String sFolderName)` Get folder from current mail store
`java.lang.String` | `getHostName()` Get column incoming_server of k_user_mail
`java.lang.String` | `getMBoxDirectory()`
`java.util.Properties` | `getProperties()`
`Session` | `getSession()` Get incoming mail server Session This method calls JavaMail Session.getInstance() method if neccesary, using properties currently set at this instance and SilentAuthenticator as Authenticator subclass
`Session` | `getSmtpSession()` Get outgoing mail server Session This method calls JavaMail Session.getInstance() method if neccesary, using properties currently set at this instance and SilentAuthenticator as Authenticator subclass
`Store` | `getStore()` Get Store This method calls Session.getStore() and Store.connect() if neccesary.
`Transport` | `getTransport()` Get Transport This method calls Session.getTransport() and Transport.connect() if neccesary
`URLName` | `getURL()`
`boolean` | `isStoreConnected()`
`boolean` | `isTransportConnected()`
`java.lang.String[]` | `listFolderMessages(java.lang.String sFolderName)` Get a list of all folder messages which are not deleted Messages are returned in ascending date order, oldest messages are returned first
`java.lang.String[]` | `listRecentMessages(java.lang.String sFolderName, int iMaxMsgs)` Get a list of most recent folder messages which are not deleted, answered or marked as spam Messages are returned in descending date order, most recent messages are returned first
`void` | `sendMessage(Message oMsg)`
`void` | `sendMessage(Message oMsg, Address[] aAddrs)`
`void` | `sendMessage(Message oMsg, Address[] aAdrFrom, Address[] aAdrReply, Address[] aAdrTo, Address[] aAdrCc, Address[] aAdrBcc)`
`int` | `sendMessage(java.lang.String sSubject, java.lang.String sFromPersonal, java.lang.String sFromAddr, java.lang.String sReplyAddr, java.lang.String[] aRecipients, RecipientType[] aRecType, java.lang.String sTextBody, java.lang.String sHtmlBody, java.lang.String sEncoding, java.lang.String sId, java.lang.String[] aAttachmentsPath, java.lang.String sUserDir, java.io.PrintStream oOut)` Send e-mail message
`int` | `sendMessage(java.lang.String sSubject, java.lang.String sFromPersonal, java.lang.String sFromAddr, java.lang.String sReplyAddr, java.lang.String[] aRecipients, RecipientType oRecType, java.lang.String sTextBody, java.lang.String sHtmlBody, java.lang.String sEncoding, java.lang.String sId, java.lang.String[] aAttachmentsPath, java.lang.String sUserDir, java.io.PrintStream oOut)`
`void` | `setAccountName(java.lang.String aAccName)` Set incoming mail account name
`void` | `setAuthStr(java.lang.String aAutStr)` Set incoming mail password
`void` | `setHostName(java.lang.String sName)` Set incoming mail host name or IP address
`void` | `setMBoxDirectory(java.lang.String sDir)`
`void` | `setProperties(java.util.Properties oPropties)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SessionHandler

    public SessionHandler()

  Default constructor

### SessionHandler

    public SessionHandler(java.util.Properties oMailProperties)
                   throws java.lang.NullPointerException

  Create session using given Properties

  Parameters:
    `oMailProperties` - Properties

    Property | Description> | Default value
    --- | --- | ---
    mail.user | Store and transport user |
    mail.password | Store and transport password |
    mail.store.protocol |  | pop3
    mail.transport.protocol |  | smtp
    mail.storeprotocol.host | For example: pop.mailserver.com |
    mail.storeprotocol.socketFactory.class | Only if using SSL set this value to javax.net.ssl.SSLSocketFactory |
    mail.storeprotocol.socketFactory.port | Only if using SSL |
    mail.transportprotocol.host | For example: smtp.mailserver.com |
    mail.transportprotocol.socketFactory.class | Only if using SSL set this value to javax.net.ssl.SSLSocketFactory |
    mail.transportprotocol.socketFactory.port | Only if using SSL |
    proxySet | Use proxy | false
    socksProxyHost | Proxy IP address |
    socksProxyPort | Proxy Port |

  Throws:
    `java.lang.NullPointerException` - if oMailProperties is null
  Since:
    3.1

### SessionHandler

    public SessionHandler(MailAccount oAccount)

  Create instance taking data from a MailAccount

  The data of MailAccount stored at k_user_mail table is used for initializing the connection properties

  Parameters:
    `oAccount` - MailAccount

### SessionHandler

    public SessionHandler(MailAccount oAccount,
                          java.lang.String sMBoxDirectory)

  Create instance taking data from a MailAccount and set local directory for MBOX files

  Parameters:
    `oAccount` - MailAccount
    `sMBoxDirectory` - String

Method Detail

### getAccountName

    public java.lang.String getAccountName()

  Get column incoming_account of k_user_mail

  Returns:
    String account name or null if this instance has not been initialized from a MailAccount object

### setAccountName

    public void setAccountName(java.lang.String aAccName)

  Set incoming mail account name

### getAuthStr

    public java.lang.String getAuthStr()

  Get column incoming_password of k_user_mail

  Returns:
    String password or null if this instance has not been initialized from a MailAccount object

### setAuthStr

    public void setAuthStr(java.lang.String aAutStr)

  Set incoming mail password

### getHostName

    public java.lang.String getHostName()

  Get column incoming_server of k_user_mail

  Returns:
    String

### setHostName

    public void setHostName(java.lang.String sName)

  Set incoming mail host name or IP address

### getMBoxDirectory

    public java.lang.String getMBoxDirectory()

### setMBoxDirectory

    public void setMBoxDirectory(java.lang.String sDir)

### getProperties

    public java.util.Properties getProperties()

### setProperties

    public void setProperties(java.util.Properties oPropties)

### getSession

    public Session getSession()
                       throws java.lang.IllegalStateException

  Get incoming mail server Session

  This method calls JavaMail Session.getInstance() method if neccesary, using properties currently set at this instance and SilentAuthenticator as Authenticator subclass

  Returns:
    javax.mail.Session
  Throws:
    `java.lang.IllegalStateException`
    `java.lang.NullPointerException`

### getSmtpSession

    public Session getSmtpSession()
                           throws java.lang.IllegalStateException

  Get outgoing mail server Session

  This method calls JavaMail Session.getInstance() method if neccesary, using properties currently set at this instance and SilentAuthenticator as Authenticator subclass

  Returns:
    javax.mail.Session
  Throws:
    `java.lang.IllegalStateException`
    `java.lang.NullPointerException`

### getStore

    public Store getStore()
                   throws NoSuchProviderException,
                          MessagingException

  Get Store

  This method calls Session.getStore() and Store.connect() if neccesary.

  Returns:
    javax.mail.Store
  Throws:
    `NoSuchProviderException`
    `MessagingException`

### getTransport

    public Transport getTransport()
                           throws NoSuchProviderException,
                                  MessagingException

  Get Transport

  This method calls Session.getTransport() and Transport.connect() if neccesary

  Returns:
    javax.mail.Transport
  Throws:
    `NoSuchProviderException`
    `MessagingException`

### getFolder

    public Folder getFolder(java.lang.String sFolderName)
                     throws NoSuchProviderException,
                            MessagingException

  Get folder from current mail store

  Returns:
    javax.mail.Folder
  Throws:
    `NoSuchProviderException`
    `MessagingException`

### getURL

    public URLName getURL()

### isStoreConnected

    public boolean isStoreConnected()

### isTransportConnected

    public boolean isTransportConnected()

### sendMessage

    public void sendMessage(Message oMsg)
                     throws NoSuchProviderException,
                            SendFailedException,
                            ParseException,
                            MessagingException,
                            java.lang.NullPointerException,
                            java.lang.IllegalStateException

  Throws:
    `NoSuchProviderException`
    `SendFailedException`
    `ParseException`
    `MessagingException`
    `java.lang.NullPointerException`
    `java.lang.IllegalStateException`

### listFolderMessages

    public java.lang.String[] listFolderMessages(java.lang.String sFolderName)
                                          throws AuthenticationFailedException,
                                                 NoSuchProviderException,
                                                 MessagingException

  Get a list of all folder messages which are not deleted

  Messages are returned in ascending date order, oldest messages are returned first

  Parameters:
    `sFolderName` - Folder Name, for example: "INBOX"
  Returns:
    An array of strings with format <msg> <num>[1..n]</num> <id>message unique identifier</id> <type>message content-type</type> <disposition>message content-disposition</disposition> <len>message length in bytes</len> <priority>X-Priority header</priority> <spam>X-Spam-Flag header</spam> <subject><![CDATA[message subject]]></subject> <sent>yyy-mm-dd hh:mi:ss</sent> <received>yyy-mm-dd hh:mi:ss</received> <from><![CDATA[personal name of sender]]></from> <to><![CDATA[personal name or e-mail of receiver]]></to> <size>integer size in kilobytes</size> <err>error description (if any)</err> </msg>
  Throws:
    `AuthenticationFailedException`
    `NoSuchProviderException`
    `MessagingException`
  Since:
    4.0

### listRecentMessages

    public java.lang.String[] listRecentMessages(java.lang.String sFolderName,
                                                 int iMaxMsgs)
                                          throws AuthenticationFailedException,
                                                 NoSuchProviderException,
                                                 MessagingException,
                                                 java.lang.IllegalArgumentException

  Get a list of most recent folder messages which are not deleted, answered or marked as spam

  Messages are returned in descending date order, most recent messages are returned first

  Parameters:
    `sFolderName` - Folder Name, for example: "INBOX"
    `iMaxMsgs` - Maximum number of messages to get [1..2^31-1]
  Returns:
    An array of strings with format <msg> <num>[1..n]</num> <id>message unique identifier</id> <type>message content type</type> <disposition>message content-disposition</disposition> <len>message length in bytes</len> <priority>X-Priority header</priority> <spam></spam> <subject><![CDATA[message subject]]></subject> <sent>yyy-mm-dd hh:mi:ss</sent> <received>yyy-mm-dd hh:mi:ss</received> <from><![CDATA[personal name of sender]]></from> <to><![CDATA[personal name or e-mail of receiver]]></to> <size>integer size in kilobytes</size> <err>error description (if any)</err> </msg>
  Throws:
    `AuthenticationFailedException`
    `NoSuchProviderException`
    `MessagingException`
    `java.lang.IllegalArgumentException`
  Since:
    4.0

### sendMessage

    public void sendMessage(Message oMsg,
                            Address[] aAddrs)
                     throws NoSuchProviderException,
                            SendFailedException,
                            ParseException,
                            MessagingException,
                            java.lang.NullPointerException

  Throws:
    `NoSuchProviderException`
    `SendFailedException`
    `ParseException`
    `MessagingException`
    `java.lang.NullPointerException`

### sendMessage

    public void sendMessage(Message oMsg,
                            Address[] aAdrFrom,
                            Address[] aAdrReply,
                            Address[] aAdrTo,
                            Address[] aAdrCc,
                            Address[] aAdrBcc)
                     throws NoSuchProviderException,
                            SendFailedException,
                            ParseException,
                            MessagingException,
                            java.lang.NullPointerException

  Throws:
    `NoSuchProviderException`
    `SendFailedException`
    `ParseException`
    `MessagingException`
    `java.lang.NullPointerException`

### close

    public void close()
               throws MessagingException

  Throws:
    `MessagingException`

### sendMessage

    public int sendMessage(java.lang.String sSubject,
                           java.lang.String sFromPersonal,
                           java.lang.String sFromAddr,
                           java.lang.String sReplyAddr,
                           java.lang.String[] aRecipients,
                           RecipientType[] aRecType,
                           java.lang.String sTextBody,
                           java.lang.String sHtmlBody,
                           java.lang.String sEncoding,
                           java.lang.String sId,
                           java.lang.String[] aAttachmentsPath,
                           java.lang.String sUserDir,
                           java.io.PrintStream oOut)
                    throws java.lang.NullPointerException,
                           java.io.IOException,
                           MessagingException,
                           java.lang.IllegalArgumentException,
                           java.lang.SecurityException

  Send e-mail message

  Parameters:
    `sSubject` - String e-mail Subject
    `sFromPersonal` - String Sender display name
    `sFromAddr` - String Sender e-mail address
    `sReplyAddr` - String Reply-To e-mail address
    `aRecipients` - Array of recipients e-mail addresses
    `aRecType` - Array of types for each recipient {to, cc, bcc}
    `sTextBody` - String Plain Text Message Body
    `sHtmlBody` - String HTML Text Message Body
    `sEncoding` - Character Encoding to be used
    `sId` - String Message Unique Id. Optional, may be null.
    `aAttachmentsPath` - Array of relative paths to files to be attached
    `sUserDir` - Base path for attached files
    `oOut` - PrintStream Output stream for messages verbose
  Throws:
    `java.lang.NullPointerException`
    `java.io.IOException`
    `MessagingException`
    `java.lang.IllegalArgumentException`
    `java.lang.SecurityException`

### sendMessage

    public int sendMessage(java.lang.String sSubject,
                           java.lang.String sFromPersonal,
                           java.lang.String sFromAddr,
                           java.lang.String sReplyAddr,
                           java.lang.String[] aRecipients,
                           RecipientType oRecType,
                           java.lang.String sTextBody,
                           java.lang.String sHtmlBody,
                           java.lang.String sEncoding,
                           java.lang.String sId,
                           java.lang.String[] aAttachmentsPath,
                           java.lang.String sUserDir,
                           java.io.PrintStream oOut)
                    throws java.lang.NullPointerException,
                           java.io.IOException,
                           MessagingException,
                           java.lang.IllegalArgumentException,
                           java.lang.SecurityException

  Throws:
    `java.lang.NullPointerException`
    `java.io.IOException`
    `MessagingException`
    `java.lang.IllegalArgumentException`
    `java.lang.SecurityException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD