SOAj Mail v. 1.3


info.soaj.mail.util
Class SjUtilJavaMail

java.lang.Object
  extended by info.soaj.mail.util.SjUtilJavaMail

public class SjUtilJavaMail
extends java.lang.Object

This utility class contains email methods invoking the JavaMail API.

There are two options for determining if processing was successful. First, a full range of exceptions are thrown by default. Secondly, the email attributes object indicates whether or not exceptions are suppressed.

If exceptions are suppressed a boolean return value of 'false' indicates unsuccessful method completion. An example scenario where this approach is beneficial is when emailing exception information. One would not want an exception thrown if emailing an exception or a loop would occur.

Copyright (c) 2006 - 2009 by Global Technology Consulting Group, Inc. at gtcGroup.com .

Since:
v. 1.0
Author:
MarvinToll@gtcGroup.com

Field Summary
private static java.util.Date beginDay
          This date supports the maximum number of email messages per day.
private static java.util.Date beginHour
          This date supports the maximum number of email messages per hour.
private static java.lang.String CLASS_NAME
          CLASS_NAME
private static int numberOfMessagesSentThisDay
          This integer represents the number of email messages sent.
private static int numberOfMessagesSentThisHour
          This integer represents the number of email messages sent.
 
Constructor Summary
private SjUtilJavaMail()
          Constructor - Private
 
Method Summary
private static java.lang.String appendText(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          Text
static boolean isMaximumExceptionMessagesExceeded(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin)
          This method ensures that the declared maximum number of email messages is not exceeded.
private static javax.mail.Session sendAuthenticated(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes, java.util.Properties emailProperties)
          Instantiate Session - with or without authentication.
private static javax.mail.internet.InternetAddress[] sendBccAddress(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          CC Address(es)
private static javax.mail.internet.InternetAddress[] sendCcAddress(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          CC Address(es)
private static java.lang.String sendFromAddress(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          From Address
private static java.lang.String[] sendRecipients(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          Recipients
private static java.lang.String sendSmtpHost(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes, java.util.Properties emailProperties)
          SMTP Host
private static boolean sendSmtpPassword(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes, java.util.Properties emailProperties)
          SMTP User Name
private static java.lang.String sendSmtpPort(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes, java.util.Properties emailProperties)
          SMTP Port - Default = 25
private static boolean sendSmtpUserName(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes, java.util.Properties emailProperties)
          SMTP User Name
private static void sendSocksProxy(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          Socks Proxy
private static java.lang.String sendSubject(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          Subject
static boolean sendTextEmail(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin, info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
          This method sends an email message using JavaMail.
private static boolean throwException(info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes, java.lang.Throwable e, java.lang.String exceptionMessage)
          This convenience method throws an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME

private static final java.lang.String CLASS_NAME
CLASS_NAME


beginHour

private static java.util.Date beginHour
This date supports the maximum number of email messages per hour.


beginDay

private static java.util.Date beginDay
This date supports the maximum number of email messages per day.


numberOfMessagesSentThisHour

private static int numberOfMessagesSentThisHour
This integer represents the number of email messages sent.


numberOfMessagesSentThisDay

private static int numberOfMessagesSentThisDay
This integer represents the number of email messages sent.

Constructor Detail

SjUtilJavaMail

private SjUtilJavaMail()
Constructor - Private

Method Detail

sendTextEmail

public static boolean sendTextEmail(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                    info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
This method sends an email message using JavaMail.

Parameters:
emailPlugin -
emailAttributes -
Returns:
boolean - 'True' indicates the message was successfully sent.

appendText

private static java.lang.String appendText(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                           info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
                                    throws java.lang.Exception
Text

Parameters:
emailPlugin -
emailAttributes -
Returns:
String
Throws:
java.lang.Exception

sendSubject

private static java.lang.String sendSubject(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                            info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
                                     throws java.lang.Exception
Subject

Parameters:
emailPlugin -
emailAttributes -
Returns:
String
Throws:
java.lang.Exception

sendRecipients

private static java.lang.String[] sendRecipients(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                                 info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
                                          throws java.lang.Exception
Recipients

Parameters:
emailPlugin -
emailAttributes -
Returns:
String[]
Throws:
java.lang.Exception

sendCcAddress

private static javax.mail.internet.InternetAddress[] sendCcAddress(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                                                   info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
                                                            throws java.lang.Exception
CC Address(es)

Parameters:
emailPlugin -
emailAttributes -
Returns:
InternetAddress[]
Throws:
java.lang.Exception

sendBccAddress

private static javax.mail.internet.InternetAddress[] sendBccAddress(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                                                    info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
                                                             throws java.lang.Exception
CC Address(es)

Parameters:
emailPlugin -
emailAttributes -
Returns:
InternetAddress[]
Throws:
java.lang.Exception

sendFromAddress

private static java.lang.String sendFromAddress(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                                info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
                                         throws java.lang.Exception
From Address

Parameters:
emailPlugin -
emailAttributes -
Returns:
String
Throws:
java.lang.Exception

sendSmtpHost

private static java.lang.String sendSmtpHost(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                             info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes,
                                             java.util.Properties emailProperties)
                                      throws java.lang.NullPointerException
SMTP Host

Parameters:
emailPlugin -
emailAttributes -
emailProperties -
Returns:
String
Throws:
java.lang.NullPointerException

sendSmtpPort

private static java.lang.String sendSmtpPort(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                             info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes,
                                             java.util.Properties emailProperties)
                                      throws java.lang.NullPointerException
SMTP Port - Default = 25

Parameters:
emailPlugin -
emailAttributes -
emailProperties -
Returns:
String
Throws:
java.lang.NullPointerException

sendSocksProxy

private static void sendSocksProxy(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                   info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes)
Socks Proxy

Parameters:
emailPlugin -
emailAttributes -

sendAuthenticated

private static javax.mail.Session sendAuthenticated(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                                    info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes,
                                                    java.util.Properties emailProperties)
Instantiate Session - with or without authentication.

Parameters:
emailPlugin -
emailAttributes -
emailProperties -
Returns:
Session

sendSmtpUserName

private static boolean sendSmtpUserName(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                        info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes,
                                        java.util.Properties emailProperties)
                                 throws java.lang.NullPointerException
SMTP User Name

Parameters:
emailPlugin -
emailAttributes -
emailProperties -
Returns:
boolean Indicates whether a SMTP User Name was set.
Throws:
java.lang.NullPointerException

sendSmtpPassword

private static boolean sendSmtpPassword(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin,
                                        info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes,
                                        java.util.Properties emailProperties)
                                 throws java.lang.NullPointerException
SMTP User Name

Parameters:
emailPlugin -
emailAttributes -
emailProperties -
Returns:
boolean Indicates whether a SMTP Password was set.
Throws:
java.lang.NullPointerException

throwException

private static boolean throwException(info.soaj.core.attribute.SjAttributesForAbstractPluginEmail emailAttributes,
                                      java.lang.Throwable e,
                                      java.lang.String exceptionMessage)
                               throws SjMailExceptionSendingEmail
This convenience method throws an exception.

Parameters:
emailAttributes -
e -
exceptionMessage -
Returns:
boolean Indicates if message successfully sent.
Throws:
SjMailExceptionSendingEmail

isMaximumExceptionMessagesExceeded

public static boolean isMaximumExceptionMessagesExceeded(info.soaj.core.plugin.SjAbstractPluginEmail emailPlugin)
This method ensures that the declared maximum number of email messages is not exceeded.

Parameters:
emailPlugin -
Returns:
boolean

SOAj Mail v. 1.3


Copyright (c) 2006 - 2009 by Global Technology Consulting Group, Inc. at gtcGroup.com.
Use is authorized, provided the source is acknowledged by inclusion of this copyright notice.