com.sibvisions.util
Class Mail

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

public final class Mail
extends Authenticator

The Mail class is a utility class for sending mails.


Field Summary
static String CONTENT_HTML
          the html content.
static String CONTENT_TEXT
          the plain text content.
 
Constructor Summary
Mail(String pHost, String pSmtpPort)
          Creates a new instance of Mail with a specific mailserver and smtp port.
Mail(String pHost, String pSmtpPort, String pUserName, String pPassword)
          Creates a new instance of Mail with a specific mailserver, smtp port and authentication credentials.
 
Method Summary
 String getContentType()
          Gets the content type.
protected  PasswordAuthentication getPasswordAuthentication()
          
 void send(String pFrom, String pTo, String pCc, String pSubject, String pText)
          Sends a plain text mail.
 void send(String pFrom, String pTo, String pCc, String pSubject, String pText, String pFilename, Object pContent)
          Sends a plain text mail.
 void setContentType(String pContentType)
          Sets the content type.
 
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 String CONTENT_TEXT
the plain text content.

See Also:
Constant Field Values

CONTENT_HTML

public static final String CONTENT_HTML
the html content.

See Also:
Constant Field Values
Constructor Detail

Mail

public Mail(String pHost,
            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(String pHost,
            String pSmtpPort,
            String pUserName,
            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 PasswordAuthentication getPasswordAuthentication()

Overrides:
getPasswordAuthentication in class Authenticator

setContentType

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

Parameters:
pContentType - the content type

getContentType

public String getContentType()
Gets the content type.

Returns:
the content type

send

public void send(String pFrom,
                 String pTo,
                 String pCc,
                 String pSubject,
                 String pText)
          throws 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:
Exception - if the send operation failed

send

public void send(String pFrom,
                 String pTo,
                 String pCc,
                 String pSubject,
                 String pText,
                 String pFilename,
                 Object pContent)
          throws 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:
Exception - if the send operation failed


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.