com.sibvisions.util
Class Mail

java.lang.Object
  extended by javax.mail.Authenticator
      extended by com.sibvisions.util.Mail

public final class Mail
extends javax.mail.Authenticator

The Mail class is a utility class for sending mails.


Field Summary
static java.lang.String CONTENT_HTML
          the html content.
static java.lang.String CONTENT_TEXT
          the plain text content.
 
Constructor Summary
Mail(java.lang.String pHost, java.lang.String pSmtpPort)
          Creates a new instance of Mail with a specific mailserver and smtp port.
Mail(java.lang.String pHost, java.lang.String pSmtpPort, java.lang.String pUserName, java.lang.String pPassword)
          Creates a new instance of Mail with a specific mailserver, smtp port and authentication credentials.
 
Method Summary
 java.lang.String getContentType()
          Gets the content type.
protected  javax.mail.PasswordAuthentication getPasswordAuthentication()
          
 java.lang.Object getProperty(java.lang.String pName)
          Gets the value of a property.
 boolean isTLSEnabled()
          Gets whether TLS is enabled.
 void send(java.lang.String pFrom, java.lang.String pTo, java.lang.String pSubject, java.lang.String pText)
          Sends a plain text mail.
 void send(java.lang.String pFrom, java.lang.String pTo, java.lang.String pCc, java.lang.String pSubject, java.lang.String pText)
          Sends a plain text mail.
 void send(java.lang.String pFrom, java.lang.String pTo, java.lang.String pCc, java.lang.String pSubject, java.lang.String pText, java.lang.String pFilename, java.lang.Object pContent)
          Sends a plain text mail.
 void send(java.lang.String pFrom, java.lang.String pTo, java.lang.String pCc, java.lang.String pBcc, java.lang.String pSubject, java.lang.String pText, java.lang.String pFilename, java.lang.Object pContent)
          Sends a plain text mail.
 void setContentType(java.lang.String pContentType)
          Sets the content type.
 void setProperty(java.lang.String pName, java.lang.String pValue)
          Sets or removes a property.
 void setTLSEnabled(boolean pEnable)
          Sets whether TLS is enabled.
 
Methods inherited from class javax.mail.Authenticator
getDefaultUserName, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingSite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_TEXT

public static final java.lang.String CONTENT_TEXT
the plain text content.

See Also:
Constant Field Values

CONTENT_HTML

public static final java.lang.String CONTENT_HTML
the html content.

See Also:
Constant Field Values
Constructor Detail

Mail

public Mail(java.lang.String pHost,
            java.lang.String pSmtpPort)
Creates a new instance of Mail with a specific mailserver and smtp port.

Parameters:
pHost - the hostname or ip address of the mailserver
pSmtpPort - the smtp port of the mailserver

Mail

public Mail(java.lang.String pHost,
            java.lang.String pSmtpPort,
            java.lang.String pUserName,
            java.lang.String pPassword)
Creates a new instance of Mail with a specific mailserver, smtp port and authentication credentials.

Parameters:
pHost - the hostname or ip address of the mailserver
pSmtpPort - the smtp port of the mailserver
pUserName - the username for smtp authentication
pPassword - the password for smtp authentication
Method Detail

getPasswordAuthentication

protected javax.mail.PasswordAuthentication getPasswordAuthentication()

Overrides:
getPasswordAuthentication in class javax.mail.Authenticator

setContentType

public void setContentType(java.lang.String pContentType)
Sets the content type.

Parameters:
pContentType - the content type

getContentType

public java.lang.String getContentType()
Gets the content type.

Returns:
the content type

setProperty

public void setProperty(java.lang.String pName,
                        java.lang.String pValue)
Sets or removes a property.

Parameters:
pName - the name
pValue - the value or null to remove the property

getProperty

public java.lang.Object getProperty(java.lang.String pName)
Gets the value of a property.

Parameters:
pName - the name
Returns:
the value

setTLSEnabled

public void setTLSEnabled(boolean pEnable)
Sets whether TLS is enabled.

Parameters:
pEnable - true to enable, false otherwise

isTLSEnabled

public boolean isTLSEnabled()
Gets whether TLS is enabled.

Returns:
true if enabled, false otherwise

send

public void send(java.lang.String pFrom,
                 java.lang.String pTo,
                 java.lang.String pSubject,
                 java.lang.String pText)
          throws java.lang.Exception
Sends a plain text mail.

Parameters:
pFrom - the sender
pTo - the recipient(s) comma separated
pSubject - the subject of the message
pText - the text of the message
Throws:
java.lang.Exception - if the send operation failed

send

public void send(java.lang.String pFrom,
                 java.lang.String pTo,
                 java.lang.String pCc,
                 java.lang.String pSubject,
                 java.lang.String pText)
          throws java.lang.Exception
Sends a plain text mail.

Parameters:
pFrom - the sender
pTo - the recipient(s) comma separated
pCc - the carbon copy recipient(s) comma separated
pSubject - the subject of the message
pText - the text of the message
Throws:
java.lang.Exception - if the send operation failed

send

public void send(java.lang.String pFrom,
                 java.lang.String pTo,
                 java.lang.String pCc,
                 java.lang.String pSubject,
                 java.lang.String pText,
                 java.lang.String pFilename,
                 java.lang.Object pContent)
          throws java.lang.Exception
Sends a plain text mail.

Parameters:
pFrom - the sender
pTo - the recipient(s) comma separated
pCc - the carbon copy recipient(s) comma separated
pSubject - the subject of the message
pText - the text of the message
pFilename - the file name
pContent - the content
Throws:
java.lang.Exception - if the send operation failed

send

public void send(java.lang.String pFrom,
                 java.lang.String pTo,
                 java.lang.String pCc,
                 java.lang.String pBcc,
                 java.lang.String pSubject,
                 java.lang.String pText,
                 java.lang.String pFilename,
                 java.lang.Object pContent)
          throws java.lang.Exception
Sends a plain text mail.

Parameters:
pFrom - the sender
pTo - the recipient(s) comma separated
pCc - the carbon copy recipient(s) comma separated
pBcc - the carbon copy recipient(s) comma separated
pSubject - the subject of the message
pText - the text of the message
pFilename - the file name
pContent - the content
Throws:
java.lang.Exception - if the send operation failed


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.